namedDefaultScope

fun namedDefaultScope(name: String, corePoolSize: Int, job: Job? = null, errorHandler: CoroutineExceptionHandler? = null, context: CoroutineContext = EmptyCoroutineContext): CoroutineScope(source)

Creates a CoroutineScope with incremental thread naming.

As per ScheduledThreadPoolExecutor, a fixed-size thread pool using corePoolSize threads will be used, but it is almost never a good idea to set a corePoolSize to zero because it may leave the pool without threads to handle tasks once they become eligible to run.

Parameters

name

The base name of the threads and coroutines, will be prefixed by the number if corePoolSize 1

corePoolSize

The number of threads to keep in the pool, even if they are idle, must not be negative

job

The parent job used for coroutines which can be used to cancel all children, uses SupervisorJob by default

errorHandler

The CoroutineExceptionHandler used for handling uncaught exceptions, uses a logging handler which cancels the parent job on Error by default

context

Any additional context to add to the scope, uses EmptyCoroutineContext by default


fun namedDefaultScope(coroutineName: String, executor: Executor, job: Job? = null, errorHandler: CoroutineExceptionHandler? = null, context: CoroutineContext = EmptyCoroutineContext): CoroutineScope(source)

Creates a CoroutineScope with incremental thread naming.

Parameters

coroutineName

The name of the coroutines

executor

The executor running the coroutines

job

The parent job used for coroutines which can be used to cancel all children, uses SupervisorJob by default

errorHandler

The CoroutineExceptionHandler used for handling uncaught exceptions, uses a logging handler which cancels the parent job on Error by default

context

Any additional context to add to the scope, uses EmptyCoroutineContext by default