<div dir="ltr">Hi,<div><br></div><div>I was wondering, if I create a library that uses scoped value,</div><div>and for some reason I am unable to prevent the user from running something without providing the scoped value.</div><div><br></div><div>Is there a performance hit if I set up a static method that would guard .get() and throw a more descriptive</div><div>error to what needs to be done to use the library correctly ?</div><div><br></div><div>If there is a performance hit, it would be nice to be able to define additional custom message when </div><div>scoped value is not present and an error is thrown.</div><div><br></div><div><br></div><div><br></div><div><br></div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Mon, Apr 14, 2025 at 9:43 PM Mark Reinhold <<a href="mailto:mark.reinhold@oracle.com">mark.reinhold@oracle.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><a href="https://openjdk.org/jeps/506" rel="noreferrer" target="_blank">https://openjdk.org/jeps/506</a><br>
<br>
Summary: Introduce scoped values, which enable a method to share<br>
immutable data both with its callees within a thread, and with child<br>
threads. Scoped values are easier to reason about than thread-local<br>
variables. They also have lower space and time costs, especially when<br>
used together with virtual threads (JEP 444) and structured concurrency<br>
(JEP 505).<br>
<br>
- Mark</blockquote></div>