A
ThreadPoolExecutor
that upon dispatching automatically updates which thread runs
within which
ServerSideContext
using supplied
ContextTrackingExecutor.trackers
.
Usually instances correspond 1-1 with some type of blocking or time consuming operations, such
as CPU/GPU intensive calculations or blocking network communication.
In case of network operations, a given threadPool size should usually correspond to the pool size
of the connections to a given resource.
In case CPU/GPU intensive operations, it should usually correspond to the number of given cores
available to the process.
Instances are usually created at app startup, stored on static vars and/or configured for
injection using
toInstance(...)
with
@Named
annotation.
Note: as long as accessed scoped objects are thread-safe, it is generally ok to handle a single
context in multiple threads (for example by using one of
invokeAll(...)
/
invokeAny(...)
methods, or dispatching and then
continuing work also on the original thread).