andreasmattsson
09/18/2017, 9:16 AMkonan.worker.*
APIs to do some background processing (in a loop), and it's working well, but now I'd like to add an ability to gracefully cancel/abort (early-exit) from the background loop.
What's the correct way to implement this? Is there some flag I can check for in my background loop that is set when requestTermination
has been called?
I understand there are restrictions on sharing state, so for example I get an IllegalStateException
if I try to pass in a BooleanVar
into my worker args.olonho
09/18/2017, 9:21 PMandreasmattsson
09/19/2017, 7:41 AMworker.schedule(TransferMode.CHECKED, { WorkerArgs(stringVar) }, ::workerFunction)
But this does work:
worker.schedule(TransferMode.CHECKED, { WorkerArgs("$stringVar") }, ::workerFunction)
(e.g. making a new string with the same contents)
Looks kinda ugly though, any suggestions?olonho
09/19/2017, 2:16 PM