C-Thread-Pool icon indicating copy to clipboard operation
C-Thread-Pool copied to clipboard

question about threads_keepalive variable.

Open wind0ws opened this issue 5 years ago • 1 comments

Hi, thanks for this awesome lib.

In thpool.c (line 37), here is static volatile int threads_keepalive; , why not put threads_keepalive on struct thpool_?

Assume the following scenario:

  1. Create thread pool A (Now threads_keepalive is set to 1);
  2. Call add_task on thread pool A;
  3. Create thread pool B (Now threads_keepalive is set to 1);
  4. Call add_task on thread pool B;
  5. Destroy thread pool A (Now threads_keepalive is set to 0);
  6. Call add_task on thread pool B ; ( task won't execute, because of threads_keepalive == 0 )

wind0ws avatar Jul 10 '20 08:07 wind0ws

Just stumbled with similar issue. In my application, thread pool B isn't scheduling tasks if thread pool A is destroyed.

forGGe avatar Apr 13 '21 18:04 forGGe