projectmoon
06/05/2019, 1:29 PMrunBlocking
... use case here is that i need to, once a day run a bunch of operations as coroutines. currently this is a java scheduled executor, but i want to switch to coroutines for the actual running of the code.projectmoon
06/05/2019, 1:29 PMrunBlocking
and a bunch of launch
calls inside of thisDico
06/05/2019, 1:57 PMrunBlocking
scope has only 1 thread.
Use a scope like this,
val scope = CoroutineScope(SupervisorJob() + Dispatchers.Default)
Then
scope.launch { /*worker code */}
projectmoon
06/05/2019, 2:24 PMprojectmoon
06/05/2019, 2:24 PMprojectmoon
06/05/2019, 2:27 PMtimer
, but otherwise i guess i can use a scheduling library to actually fire up the workersDico
06/05/2019, 2:36 PMdelay
function after starting the coroutineprojectmoon
06/05/2019, 2:37 PMprojectmoon
06/05/2019, 3:10 PMDico
06/05/2019, 3:53 PMprojectmoon
06/05/2019, 5:02 PMgildor
06/06/2019, 12:48 AMUse scope like thisI don't see why scope is needed in this case, just GlobalScope is fine for non cancellable scope of some background tasks
Dico
06/06/2019, 2:24 AMgildor
06/06/2019, 2:25 AMval scope = CoroutineScope(SupervisorJob() + Dispatchers.Default)
to someone who doesn’t understand scopesgildor
06/06/2019, 2:25 AMgildor
06/06/2019, 2:26 AMJob
Dico
06/06/2019, 2:28 AMgildor
06/06/2019, 2:32 AMprojectmoon
06/06/2019, 10:30 AMprojectmoon
06/06/2019, 10:34 AMDico
06/06/2019, 1:39 PMprojectmoon
06/06/2019, 2:04 PM