public class CoroutineContext extends CoroutineEnvironment
Coroutines
.Constructor and Description |
---|
CoroutineContext()
Creates a new instance that uses the
common thread pool as the executor. |
CoroutineContext(java.util.concurrent.Executor rExecutor)
Creates a new instance with a specific coroutine executor.
|
CoroutineContext(java.util.concurrent.Executor rExecutor,
java.util.concurrent.ScheduledExecutorService rScheduler)
Creates a new instance with a specific coroutine executor and scheduler.
|
Modifier and Type | Method and Description |
---|---|
void |
awaitAllScopes()
Blocks until the coroutines of all
scopes in this
context have finished execution. |
java.util.concurrent.Executor |
getExecutor()
Returns the executor to be used for the execution of the steps of a
Coroutine . |
java.util.concurrent.ScheduledExecutorService |
getScheduler()
Returns the executor to be used for the execution of timed steps in a
Coroutine . |
long |
getScopeCount()
Returns the number of currently active
scopes . |
createChannel, getChannel, hasChannel, removeChannel
deleteRelation, get, getRelation, getRelations, notifyRelationListeners, readRelations, relationsEqual, relationsHashCode, relationsString, set, set, toString, transform, writeRelations
public CoroutineContext()
common thread pool
as the executor.public CoroutineContext(java.util.concurrent.Executor rExecutor)
ScheduledExecutorService
interface
it will also be used for scheduling purposes.rExecutor
- The coroutine executorpublic CoroutineContext(java.util.concurrent.Executor rExecutor, java.util.concurrent.ScheduledExecutorService rScheduler)
rExecutor
- The coroutine executorrScheduler
- The scheduled executor servicepublic void awaitAllScopes()
scopes
in this
context have finished execution. If no coroutines are running or all have
finished execution already this method returns immediately.public java.util.concurrent.Executor getExecutor()
Coroutine
.public java.util.concurrent.ScheduledExecutorService getScheduler()
Coroutine
. If no scheduler has been set in the constructor or
created before a new instance with a pool size of 1 will be created by
invoking Executors.newScheduledThreadPool(int)
.public long getScopeCount()
scopes
.
This will only be a momentary value as the execution of the coroutines in
the scopes happens asynchronously and some coroutines may finish while
querying this count.