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

Resuming a threadpool resumes all

Open Pithikos opened this issue 10 years ago • 2 comments

At the moment pause/resume synchronisation commands affect all thread pools. Someone issuing thpool_pause(thpool) will cause all thread pools to pause for example even if only one thread pool is passed as argument.

To work around this, all thread specific variables should be bundled inside the thread pool structure.

(initial report: https://github.com/Pithikos/C-Thread-Pool/pull/11)

Pithikos avatar Apr 17 '15 11:04 Pithikos

I see that thpool_resume() is global, but doesn't the pthread_kill(thpool_p->threads[n]->pthread, SIGUSR1) in thpool_pause() keep the pausing thread pool specific?

marwankallal avatar Oct 08 '16 22:10 marwankallal

You're probably right. Not sure why I wrote that when I did. In any case this should be changed since it's not consistent.

As I see it either thpool_resume should resume only the given threadpool or in the short term it should be renamed to thpool_resume_all to make it clearer what's happening, and then it shouldn't take any arguments either since it acts on a global variable.

Resuming a single thread pool probably requires a bit more work; a variable on the thread pool itself instead of a global and then probably some thinking on how the signalling should work (thread_hold).

Pithikos avatar Oct 09 '16 08:10 Pithikos