Skip to content

Fallback IOLocal#unsafeThreadLocal by a true ThreadLocal#4200

Closed
armanbilge wants to merge 2 commits intotypelevel:series/3.xfrom
armanbilge:topic/iolocal-propagation-fallback
Closed

Fallback IOLocal#unsafeThreadLocal by a true ThreadLocal#4200
armanbilge wants to merge 2 commits intotypelevel:series/3.xfrom
armanbilge:topic/iolocal-propagation-fallback

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.

@armanbilge
Copy link
Member Author

We decided it's too evil.

because there is no way to know if you are currently running in a fiber or not.

We are going to do this instead.

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