Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fallback IOLocal#unsafeThreadLocal by a true ThreadLocal #4200

Draft
wants to merge 2 commits into
base: series/3.x
Choose a base branch
from

Conversation

armanbilge
Copy link
Member

tl;dr is that for the IOLocalContextStorage in typelevel/otel4s#214 to work for arbitrary Java libraries, it must properly implement the ContextStorage API even when used in a context outside of IOFiber. To accomplish this, we can make ThreadLocals returned by IOLocal#unsafeThreadLocal behave as a true ThreadLocal when used outside of an IOFiber. This is not currently possible to implement in userland because there is no way to know if you are currently running in a fiber or not.

@djspiewak
Copy link
Member

This is pretty evil. :( Also remember the only way you could get an IOLocal in the first place in this type of situation is if you created one inside of IO or unsafely and then yolo'd it out into thread land.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants