Marcus Ilgner
07/12/2023, 9:17 AMCLOVIS
07/12/2023, 9:28 AMsuspend
. suspend
functions can only be called in suspend
functions. Of course, we need to be able to call the first suspend
function, and we do this on a CoroutineScope
, which contains a CoroutineContext
. The thread pool is configured as part of the Dispatcher
, one of the configuration elements of CoroutineContext
.CLOVIS
07/12/2023, 9:28 AMSam
07/12/2023, 9:31 AMparMap
function has an optional parameter to limit the number of sub-computations to create, which might be something like what you’re looking for. But parallelism is not introduced until you actually run the function, and the level of parallelism is controlled by the CoroutineDispatcher
.Sam
07/12/2023, 9:33 AMMarcus Ilgner
07/12/2023, 9:34 AM