Dobby  3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
Classes | Public Types | Public Member Functions | Private Attributes | List of all members
DobbyWorkQueue Class Reference
Collaboration diagram for DobbyWorkQueue:
Collaboration graph
[legend]

Classes

struct  WorkItem
 

Public Types

using WorkFunc = std::function< void()>
 

Public Member Functions

void run ()
 Runs the event loop. More...
 
bool runFor (const std::chrono::milliseconds &msecs)
 Runs the event loop for msecs milliseconds. More...
 
bool runUntil (const std::chrono::steady_clock::time_point &deadline)
 Runs the event loop until the deadline time passes. More...
 
void exit ()
 Unblocks the runXXX functions.
 
bool doWork (WorkFunc &&work)
 Posts a work job onto the queue and waits till it completes. More...
 
bool postWork (WorkFunc &&work)
 Posts a work job onto the queue. More...
 

Private Attributes

uint64_t mWorkCounter
 
bool mExitRequested
 
std::atomic< std::thread::id > mRunningThreadId
 
AICommon::Mutex mWorkQueueLock
 
AICommon::ConditionVariable mWorkQueueCond
 
std::queue< WorkItemmWorkQueue
 
AICommon::Mutex mWorkCompleteLock
 
AICommon::ConditionVariable mWorkCompleteCond
 
uint64_t mWorkCompleteCounter
 

Member Function Documentation

◆ doWork()

bool DobbyWorkQueue::doWork ( WorkFunc &&  work)

Posts a work job onto the queue and waits till it completes.

This queues the work item and then returns. It is thread safe, it is safe to call from the thread running the event loop or from another thread.

Parameters
[in]workThe work function to execute.
Returns
true.

◆ postWork()

bool DobbyWorkQueue::postWork ( WorkFunc &&  work)

Posts a work job onto the queue.

This just queues the work item and then returns. It is thread safe, it is safe to call from the thread running the event loop or from another thread.

Parameters
[in]workThe work function to execute.
Returns
true.

◆ run()

void DobbyWorkQueue::run ( )

Runs the event loop.

This will block - running the event loop until exit() is called.

◆ runFor()

bool DobbyWorkQueue::runFor ( const std::chrono::milliseconds &  msecs)

Runs the event loop for msecs milliseconds.

This will block - running the event loop for a fixed amount of time. This will return when either the timeout expires or exit() is called.

Parameters
[in]deadlineThe deadline time.
Returns
true.

◆ runUntil()

bool DobbyWorkQueue::runUntil ( const std::chrono::steady_clock::time_point &  deadline)

Runs the event loop until the deadline time passes.

This will block - running the event loop for a fixed amount of time. This will return when either the timeout expires or exit() is called.

Parameters
[in]deadlineThe deadline time.
Returns
true.

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