ROSE 0.11.145.147
Public Types | Public Member Functions | List of all members
Sawyer::WorkFifo< T > Class Template Reference

Description

template<class T>
class Sawyer::WorkFifo< T >

First-in-first-out work queue.

This simple work queue is meant to demonstrate the interface used by processWorkList. New work is inserted at the back of the FIFO and consumed from the front. Only one type and three public member functions are necessary. The member functions must be thread safe if any of them are called from worker threads, otherwise they don't need to be thread safe since the processWorkList will syncronize calls to this object.

Definition at line 23 of file WorkList.h.

#include <Sawyer/WorkList.h>

Public Types

typedef T Item
 The type that represents one unit of work.
 

Public Member Functions

void insert (const Item &item)
 Insert one unit of work into the queue.
 
bool isEmpty () const
 Test whethere the queue is empty.
 
Item next ()
 Remove and return the next item of work.
 

Member Typedef Documentation

◆ Item

template<class T >
typedef T Sawyer::WorkFifo< T >::Item

The type that represents one unit of work.

Definition at line 29 of file WorkList.h.

Member Function Documentation

◆ insert()

template<class T >
void Sawyer::WorkFifo< T >::insert ( const Item item)
inline

Insert one unit of work into the queue.

Definition at line 32 of file WorkList.h.

◆ isEmpty()

template<class T >
bool Sawyer::WorkFifo< T >::isEmpty ( ) const
inline

Test whethere the queue is empty.

Definition at line 38 of file WorkList.h.

◆ next()

template<class T >
Item Sawyer::WorkFifo< T >::next ( )
inline

Remove and return the next item of work.

This is only called when isEmpty returns true.

This function is allowed to block to wait for other work to complete, which can be useful when the work list has more work to do but all that work depends on the completion of work that's already underway. Determining when the other work completes can be done by having the processWorkList functor signal a condition variable on which this function is waiting.

Definition at line 51 of file WorkList.h.


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