stcarrez / ada-util

Ada Utility Library - Composing streams, processes, logs, serialization, encoders and more
Apache License 2.0
69 stars 14 forks source link

Executor does not always stop the worker tasks #53

Closed stcarrez closed 6 months ago

stcarrez commented 6 months ago

The Util.Executors.Stop procedure does not always stop correctly the worker tasks.

It looks at the tasks and enqueue a stop work to tell each active task to stop. The issue is that it enqueue such stop work while checking and iterating over the list of tasks. As soon as it enqueue a stop work, it is possible that a running task, not yet checked as par of the iteration, dequeues the stop job and stops immediately. Then, at the next iteration that task is seen as terminated and no stop work is enqueue. We therefore miss one (or more) stop job.