Skip to content

Commit

Permalink
Fix DynTaskThreadPool create_thread thread safety (#509)
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinEady committed Mar 7, 2023
1 parent d9fd8d4 commit a85131f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pol-core/clib/threadhelp.cpp
Expand Up @@ -530,14 +530,14 @@ size_t DynTaskThreadPool::threadpoolsize() const

void DynTaskThreadPool::create_thread()
{
std::lock_guard<std::mutex> guard( _pool_mutex );
for ( const auto& worker : _threads )
{
if ( !worker->isbusy() ) // check for a idle instance
{
return;
}
}
std::lock_guard<std::mutex> guard( _pool_mutex );
size_t thread_num = _threads.size();
_threads.emplace_back( new PoolWorker( this, _name + " " + fmt::FormatInt( thread_num ).str() ) );
ERROR_PRINT << "create pool worker " << _name << " " << thread_num << "\n";
Expand Down

0 comments on commit a85131f

Please sign in to comment.