You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Structured Concurrency has been in incubation in Java 19 and 20 and might be part of Java 21, in which case the Concurrency specification should address how it pertains to Jakarta EE.
The main way of interacting with Structured Concurrency is StructuredTaskScope, which has a fork method that accepts a Callable task. There is no way provided for the Jakarta EE Concurrency specification to automatically tie into it.
There are some steps that users can take manually to leverage existing APIs from the Jakarta EE Concurrency specification to ensure that their tasks run with context.
At the most granular level, you can use the ContextService.contextualCallable method that we added in Jakarta EE 10 to pre-contextualize Callables that you supply to the fork method.
There is also a constructor that you can use to designate a specific ThreadFactory to be used by the StructuredTaskScope. The ThreadFactory could be a ManagedThreadFactory,
The above is what will be possible if we don't do anything new in the Jakarta EE Concurrency spec for this. There will be the above ways of contextualizing tasks, but no ways of constraining concurrency.
For my opinion, the structured task scope is similar to Kotlin Coroutines scope in concept.
I think adding an annotation(the functionality is similar to Kotlin suspend and CoroutinesScope) on method to wrap current execution into a constructed task scope.
But like async support, how to support the context prorogation seamlessly in background without copying context data explicitly .
Structured Concurrency has been in incubation in Java 19 and 20 and might be part of Java 21, in which case the Concurrency specification should address how it pertains to Jakarta EE.
The main way of interacting with Structured Concurrency is StructuredTaskScope, which has a fork method that accepts a
Callable
task. There is no way provided for the Jakarta EE Concurrency specification to automatically tie into it.There are some steps that users can take manually to leverage existing APIs from the Jakarta EE Concurrency specification to ensure that their tasks run with context.
At the most granular level, you can use the ContextService.contextualCallable method that we added in Jakarta EE 10 to pre-contextualize Callables that you supply to the fork method.
There is also a constructor that you can use to designate a specific ThreadFactory to be used by the StructuredTaskScope. The ThreadFactory could be a ManagedThreadFactory,
The above is what will be possible if we don't do anything new in the Jakarta EE Concurrency spec for this. There will be the above ways of contextualizing tasks, but no ways of constraining concurrency.
StructuredTaskScope can be extended with subclasses. It even provides a couple of built-in ones:
https://download.java.net/java/early_access/jdk20/docs/api/jdk.incubator.concurrent/jdk/incubator/concurrent/StructuredTaskScope.ShutdownOnFailure.html
https://download.java.net/java/early_access/jdk20/docs/api/jdk.incubator.concurrent/jdk/incubator/concurrent/StructuredTaskScope.ShutdownOnSuccess.html
The Jakarta EE Concurrency specification could do something with subclasses and maybe let you obtain StructuredTaskScopes from managed executors if we thought that would be useful. More investigation is needed.
The text was updated successfully, but these errors were encountered: