Scroom  0.14
Scroom::Detail::ThreadPool::QueueImpl Class Reference

#include <queue.hh>

Collaboration diagram for Scroom::Detail::ThreadPool::QueueImpl:
Collaboration graph

Public Types

using Ptr = boost::shared_ptr< QueueImpl >
 

Public Member Functions

bool jobStarted ()
 
void jobFinished ()
 
void deletingQueue ()
 
int getCount ()
 

Static Public Member Functions

static Ptr create ()
 QueueImpl. More...
 

Private Member Functions

 QueueImpl ()=default
 

Private Attributes

boost::mutex mut
 
boost::condition_variable cond
 
unsigned int count {0}
 
bool isDeleted {false}
 

Detailed Description

ThreadPool::Queue implementation class.

Keeps track of whether the actual ThreadPool::Queue still exists, and whether jobs are currently being executed. When the last reference to the ThreadPool::Queue is being deleted, it calls deletingQueue(), which blocks until all jobs finish executing.

Member Typedef Documentation

◆ Ptr

Constructor & Destructor Documentation

◆ QueueImpl()

Scroom::Detail::ThreadPool::QueueImpl::QueueImpl ( )
privatedefault

Referenced by create().

Here is the caller graph for this function:

Member Function Documentation

◆ create()

QueueImpl::Ptr QueueImpl::create ( )
static

QueueImpl.

18 { return QueueImpl::Ptr(new QueueImpl()); }
Here is the call graph for this function:

◆ deletingQueue()

void QueueImpl::deletingQueue ( )

Indicate that the ThreadPool::Queue is being deleted

This sets isDeleted to true and blocks until all jobs have finished executing.

21 {
22  boost::mutex::scoped_lock lock(mut);
23  isDeleted = true;
24  while(count != 0)
25  {
26  cond.wait(lock);
27  }
28 }

◆ getCount()

int QueueImpl::getCount ( )

Return the number of jobs currently running. Used for testing

46 {
47  boost::mutex::scoped_lock const lock(mut);
48  return count;
49 }

◆ jobFinished()

void QueueImpl::jobFinished ( )

Indicate that a job is finished

39 {
40  boost::mutex::scoped_lock const lock(mut);
41  count--;
42  cond.notify_all();
43 }

◆ jobStarted()

bool QueueImpl::jobStarted ( )

Indicate that a job is being started

Return values
trueif the ThreadPool::Queue still exists
falseif the ThreadPool::Queue has been deleted
31 {
32  boost::mutex::scoped_lock const lock(mut);
33  count++;
34 
35  return !isDeleted;
36 }

Member Data Documentation

◆ cond

boost::condition_variable Scroom::Detail::ThreadPool::QueueImpl::cond
private

Gets signaled when a job completes

Referenced by deletingQueue(), and jobFinished().

◆ count

unsigned int Scroom::Detail::ThreadPool::QueueImpl::count {0}
private

Number of jobs currently running

Referenced by deletingQueue(), getCount(), jobFinished(), and jobStarted().

◆ isDeleted

bool Scroom::Detail::ThreadPool::QueueImpl::isDeleted {false}
private

true if the last reference to ThreadPool::Queue goes away

Referenced by deletingQueue(), and jobStarted().

◆ mut

boost::mutex Scroom::Detail::ThreadPool::QueueImpl::mut
private

Guard internal data

Referenced by deletingQueue(), getCount(), jobFinished(), and jobStarted().


The documentation for this class was generated from the following files:
Scroom::Detail::ThreadPool::QueueImpl::cond
boost::condition_variable cond
Definition: queue.hh:52
Scroom::Detail::ThreadPool::QueueImpl::isDeleted
bool isDeleted
Definition: queue.hh:54
Scroom::Detail::ThreadPool::QueueImpl::mut
boost::mutex mut
Definition: queue.hh:51
Scroom::Detail::ThreadPool::QueueImpl::QueueImpl
QueueImpl()=default
Scroom::Detail::ThreadPool::QueueImpl::Ptr
boost::shared_ptr< QueueImpl > Ptr
Definition: queue.hh:25
Scroom::Detail::ThreadPool::QueueImpl::count
unsigned int count
Definition: queue.hh:53