1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2025-06-18 07:17:05 +01:00

better interface for critical threaded sections

This commit is contained in:
2021-11-28 23:51:56 +00:00
parent fe8c6c6630
commit 78351a9b76
3 changed files with 14 additions and 4 deletions

View File

@ -92,6 +92,14 @@ void ThreadPool::addJob(Job newJob)
condition_.notify_one();
}
// critical section ////////////////////////////////////////////////////////////
void ThreadPool::critical(Job fn)
{
unique_lock<mutex> lock(mutex_);
fn();
}
// wait for completion /////////////////////////////////////////////////////////
void ThreadPool::terminate(void)
{

View File

@ -37,6 +37,8 @@ public:
std::mutex & getMutex(void);
// add jobs
void addJob(Job newJob);
// critical section
void critical(Job fn);
// wait for completion and terminate
void terminate(void);
private: