|
The Pedigree Project 0.1
|
#include <ProducerConsumer.h>
Collaboration diagram for ProducerConsumer:Classes | |
| struct | Task |
Public Member Functions | |
| bool | initialise () |
| void | produce (uint64_t p0=0, uint64_t p1=0, uint64_t p2=0, uint64_t p3=0, uint64_t p4=0, uint64_t p5=0, uint64_t p6=0, uint64_t p7=0, uint64_t p8=0) |
Protected Member Functions | |
| void | destroy () |
Private Member Functions | |
| virtual void | consume (uint64_t p0, uint64_t p1, uint64_t p2, uint64_t p3, uint64_t p4, uint64_t p5, uint64_t p6, uint64_t p7, uint64_t p8)=0 |
| void | consumerThread () |
Static Private Member Functions | |
| static int | thread (void *p) |
Private Attributes | |
| Mutex | m_Lock |
| ConditionVariable | m_Condition |
| List< Task * > | m_Tasks |
| void * | m_pThreadHandle = nullptr |
| bool | m_Running = false |
| bool | m_Destroyed = false |
ProducerConsumer provides a very light abstraction for a work queue.
Producer(s) push tasks into the queue by calling produce(). All of these work items are fire-and-forget - there is no way for callers to collect a return status or any other kind of information about the completion of a task. If this is important, a RequestQueue is a better choice.
The consumer, which inherits from ProducerConsumer, implements consume(). As tasks are produced, consume() is called for each task, one at a time.
In single-threaded environments, produce() just calls consume().
Definition at line 53 of file ProducerConsumer.h.
|
virtual |
Definition at line 30 of file ProducerConsumer.cc.
|
private |
Definition at line 128 of file ProducerConsumer.cc.
|
protected |
Stops and joins the consumer thread. The most-derived destructor must call this before its state or virtual dispatch table can disappear.
Definition at line 46 of file ProducerConsumer.cc.
References Semaphore::acquire(), pocketknife::attachToForCompletion(), Semaphore::release(), and ConditionVariable::signal().
| bool ProducerConsumer::initialise | ( | ) |
Definition at line 75 of file ProducerConsumer.cc.
| void ProducerConsumer::produce | ( | uint64_t | p0 = 0, |
| uint64_t | p1 = 0, |
||
| uint64_t | p2 = 0, |
||
| uint64_t | p3 = 0, |
||
| uint64_t | p4 = 0, |
||
| uint64_t | p5 = 0, |
||
| uint64_t | p6 = 0, |
||
| uint64_t | p7 = 0, |
||
| uint64_t | p8 = 0 |
||
| ) |
Definition at line 100 of file ProducerConsumer.cc.
|
staticprivate |
Definition at line 160 of file ProducerConsumer.cc.
|
private |
Definition at line 84 of file ProducerConsumer.h.
|
private |
Definition at line 89 of file ProducerConsumer.h.
|
private |
Definition at line 83 of file ProducerConsumer.h.
|
private |
Definition at line 87 of file ProducerConsumer.h.
|
private |
Definition at line 88 of file ProducerConsumer.h.
Definition at line 85 of file ProducerConsumer.h.