20 #include "pedigree/kernel/utilities/ProducerConsumer.h" 22 #if PRODUCERCONSUMER_ASYNCHRONOUS 23 #include "pedigree/kernel/LockGuard.h" 24 #include "pedigree/kernel/utilities/pocketknife.h" 27 ProducerConsumer::ProducerConsumer() =
default;
29 ProducerConsumer::~ProducerConsumer()
31 #if PRODUCERCONSUMER_ASYNCHRONOUS 47 for (
auto it : m_Tasks)
54 bool ProducerConsumer::initialise()
56 #if PRODUCERCONSUMER_ASYNCHRONOUS 66 return m_pThreadHandle !=
nullptr;
72 void ProducerConsumer::produce(
73 uint64_t p0, uint64_t p1, uint64_t p2, uint64_t p3, uint64_t p4,
74 uint64_t p5, uint64_t p6, uint64_t p7, uint64_t p8)
76 #if PRODUCERCONSUMER_ASYNCHRONOUS 77 Task *task =
new Task;
89 m_Tasks.pushBack(task);
93 consume(p0, p1, p2, p3, p4, p5, p6, p7, p8);
104 m_Condition.
wait(m_Lock);
110 else if (!m_Tasks.size())
115 Task *task = m_Tasks.popFront();
121 task->p0, task->p1, task->p2, task->p3, task->p4, task->p5,
122 task->p6, task->p7, task->p8);
130 int ProducerConsumer::thread(
void *p)
EXPORTED_PUBLIC void * runConcurrentlyAttached(int(*func)(void *), void *param)
bool acquire(size_t n=1, size_t timeoutSecs=0, size_t timeoutUsecs=0)
EXPORTED_PUBLIC int attachTo(void *handle)
WaitResult wait(Mutex &mutex, Time::Timestamp &timeout)