So it sort of looks like a DSL for a variant of ThreadLocal that gives you an idea of the lifeline of variable instead of just being global. Apparently with virtual threads they are expecting an increase in the number of running (virtual) threads several orders of magnitude larger than what was previously seen and that with ThreadLocals would just be too much.
Which stores the object referenced by `context` to the ScopedValue container `CONTEXT` ^ for the duration of the thread running `Application.handle(request,response)`.
Not really sexy, but I understand how you might really benefit if you are processing lots of data, but for most enterprise CRUD apps this seems inapplicable.
^ I think this a "monad"? I'm not a functional programmer.
The problem with thread locals is that you need to copy the value into each platform thread. And the expectation of virtual threads is that any platform thread from the pool would end up running them.
This is super applicable to any system, enterprise or not. If the web framework is running on virtual threads as soon as you query the database your virtual thread will be parked and then another platform thread could potentially pick it up finish running it. Managing thread locals in this situation would be impossible, but you still need some mechanism to manage the global context. It’s really nothing to do with data volume.
So it sort of looks like a DSL for a variant of ThreadLocal that gives you an idea of the lifeline of variable instead of just being global. Apparently with virtual threads they are expecting an increase in the number of running (virtual) threads several orders of magnitude larger than what was previously seen and that with ThreadLocals would just be too much.
So the have added this:
> ScopedVaule.where(CONTEXT, context).run(() -> Application.handle(request, response));
Which stores the object referenced by `context` to the ScopedValue container `CONTEXT` ^ for the duration of the thread running `Application.handle(request,response)`.
Not really sexy, but I understand how you might really benefit if you are processing lots of data, but for most enterprise CRUD apps this seems inapplicable.
^ I think this a "monad"? I'm not a functional programmer.
The problem with thread locals is that you need to copy the value into each platform thread. And the expectation of virtual threads is that any platform thread from the pool would end up running them.
This is super applicable to any system, enterprise or not. If the web framework is running on virtual threads as soon as you query the database your virtual thread will be parked and then another platform thread could potentially pick it up finish running it. Managing thread locals in this situation would be impossible, but you still need some mechanism to manage the global context. It’s really nothing to do with data volume.
Interesting proposal, I can see myself using this.
Tramp parameters are a common occurrence, if not avoided with care.
I see value in this proposal