The Pedigree Project  0.1
Classes | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
ProducerConsumer Class Referenceabstract

#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)
 

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
 

Detailed Description

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 52 of file ProducerConsumer.h.

Member Function Documentation

void ProducerConsumer::consumerThread ( )
private
Todo:
should really use the result here.

Definition at line 97 of file ProducerConsumer.cc.

References Semaphore::acquire(), consumerThread(), Semaphore::release(), and ConditionVariable::wait().

Referenced by consumerThread().

+ Here is the caller graph for this function:


The documentation for this class was generated from the following files: