thread-pool
thread-pool copied to clipboard
Cannot release, possible deadlock when exit ...
Stuck in ~thread_pool() => threads_[i].join();
145 pthread_join_common.c: No such file or directory.
#0 __pthread_clockjoin_ex (threadid=281473323018496, thread_return=0x0, clockid=0, abstime=
Thanks!
-Scott
If I change the code to, it will like work.
int threads_size = 0;
threads_size = threads_.size();
for (std::size_t i = 0; i < threads_size; ++i) {
threads_[i].request_stop();
}
threads_size = tasks_.size();
for (std::size_t i = 0; i < threads_size; ++i) {
tasks_[i].signal.release();
}
threads_size = threads_.size();
for (std::size_t i = 0; i < threads_size; ++i) {
//threads_[i].request_stop();
//tasks_[i].signal.release();
if (threads_[i].joinable() == true)
{
threads_[i].join();
//threads_[i].~jthread();
}
}
Thanks for the report.
Can you post what your task looks like that you're running on the thread pool?
dp::thread_pool<>* dp_pool_vars; ... dp::thread_pool dp_pool(32); dp_pool_vars = &dp_pool; ... dp_pool_vars->enqueue(write_frames_original_task, &wf_original_args_main); ... ... dp_pool.~thread_pool(); ....
Few things:
- Why are keeping a pointer to the thread pool?
- When the thread pool goes out of scope the deconstructor is automatically called. There's not need to call the thread pool dtor directly.
- Can you post the actually code that's doing the work? The lock may be due to that code.
- I need to use the thread pool in different classes and function. I use only one thread pool. And I need to declare it first and later, initialize it. That is why I need a pointer
- correct: When the thread pool goes out of scope the deconstructor is automatically called. There's not need to call the thread pool dtor directly.
- my project is too big, the zip of the source code is more than 1MB.
- I just use enqueue function to run: dp_pool_vars->enqueue(write_frames_original_task, &wf_original_args_main);
- I have been runing a few days, there is no problem.
- The only problem is when the app finish, it need to release the resources.
Okay no problem, I see.
One possible issue is that you're using enqueue() but you're not using the returned future. Consider using enqueue_detach().
Any updates on this issue? Are you still facing problems?
Thanks, no problem now!
On Fri, Apr 26, 2024 at 8:12 AM Paul T @.***> wrote:
Any updates on this issue? Are you still facing problems?
— Reply to this email directly, view it on GitHub https://github.com/DeveloperPaul123/thread-pool/issues/52#issuecomment-2079586392, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABHZOKZQLK2D34EZHZDEJHLY7JVFDAVCNFSM6AAAAAA37D7B56VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANZZGU4DMMZZGI . You are receiving this because you authored the thread.Message ID: @.***>