Files
MP-SPDZ/Processor/ThreadQueue.cpp
Marcel Keller 253ece7844 Maintenance.
2021-01-21 11:06:18 +11:00

41 lines
612 B
C++

/*
* 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;
}