Closed sabin26 closed 9 months ago
This API is not for tasks, it's for workers: after the pool has started or stopped a worker, it triggers the callback.
It does not make sense for individual workers because you control the worker's lifecycle. You can still use the future returned by Worker.start()
if you want to take action after the worker has effectively started, but you'd typically simply await that call in your code. Worker.stop()
does not return a future because it closes the channel immediately.
There's no such mechanism for tasks. WorkerPool
provides a way to get hold of a task per se via scheduleTask()
and scheduleStream()
, but there's no callback, future or stream for its lyfecycle events. Instead, these task objects have flags to describe their status (see isRunning
, isFinished
...).
Is there any similar api to
workerPool.registerWorkerPoolListener((worker, removed) {});
that can listen to task being started or completed? I didn't find one.