• Bartosz Podrygajlo's avatar
    Fix for threadpool abort function · 244621d8
    Bartosz Podrygajlo authored
    Fixed an issue where if threadpool was aborted when some threads were in a running
    state the threadpool would never exit. This was due to the fact that the thread
    terminate task (func == NULL && args == NULL) could have been pushed to queues which
    were inactive. This change adds a uint64_t mask of threads that have already exited
    so whenever the terminate task is sent to another queue, it is ensured that the queue
    used will wake up at least one tpool worker.
    
    Also added pushTpool_mask which allows to specify a subset of threads to push the task
    to but its only used internally.
    
    Also added in this commit: A way to allocate thread-safe storage for thread pool
    workers via get_tpool_worker_index. This index is unique to the thread pool worker
    within one threadpool and can be used to access arrays in a thread-safe manner.
    
    An example of such use was added in a testcase that was added which compares delay
    between actors and threadpool workers.
    244621d8
thread-pool.h 3.41 KB