d-markey / squadron

Multithreading and worker thread pool for Dart / Flutter, to offload CPU-bound and heavy I/O tasks to Isolate or Web Worker threads.
https://pub.dev/packages/squadron
MIT License
79 stars 0 forks source link

would love the ability to pause and resume workers or worker pool. #11

Closed cal-g closed 2 years ago

cal-g commented 2 years ago

Hello, it would be interesting to see if the package can be enhanced to allow for pausing and resuming workers or worker pools similarly to how dart Isolate can be paused and resumed.

d-markey commented 2 years ago

Hello @cal-g, unfortunately Web workers do not have this capacity, so there is no way to implement such a mechanism while keeping the cross-platform approach Squadron provides. So no, this can't and won't be implemented in Squadron.

I believe it would still be possible to implement that on top of Squadron, but the workers will have to collaborate in a way or another, and would be responsible to check for paused status as part of their normal workload.

I did a little bit of research and maybe https://stackoverflow.com/questions/57701464/is-it-possible-to-pause-resume-a-web-worker-externally will give you some hints?