mirror of
https://github.com/data61/MP-SPDZ.git
synced 2026-01-10 05:57:57 -05:00
Maintenance.
This commit is contained in:
40
Processor/ThreadQueue.cpp
Normal file
40
Processor/ThreadQueue.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* ThreadQueue.cpp
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "ThreadQueue.h"
|
||||
|
||||
void ThreadQueue::schedule(const ThreadJob& job)
|
||||
{
|
||||
lock.lock();
|
||||
left++;
|
||||
#ifdef DEBUG_THREAD_QUEUE
|
||||
cerr << this << ": " << left << " left" << endl;
|
||||
#endif
|
||||
lock.unlock();
|
||||
in.push(job);
|
||||
}
|
||||
|
||||
ThreadJob ThreadQueue::next()
|
||||
{
|
||||
return in.pop();
|
||||
}
|
||||
|
||||
void ThreadQueue::finished(const ThreadJob& job)
|
||||
{
|
||||
out.push(job);
|
||||
}
|
||||
|
||||
ThreadJob ThreadQueue::result()
|
||||
{
|
||||
auto res = out.pop();
|
||||
lock.lock();
|
||||
left--;
|
||||
#ifdef DEBUG_THREAD_QUEUE
|
||||
cerr << this << ": " << left << " left" << endl;
|
||||
#endif
|
||||
lock.unlock();
|
||||
return res;
|
||||
}
|
||||
Reference in New Issue
Block a user