Marine systems simulation
CoRiBoDynamics::CoreBoundThreadPool::WorkUnit Class Reference

Core bound thread unit with a task queue.

#include <AsynchronousTask.h>

+ Collaboration diagram for CoRiBoDynamics::CoreBoundThreadPool::WorkUnit:

Public Member Functions

 WorkUnit (size_t cpu_mask, mutex_queue *sub_queue)
 initialize thread and bind to the cores specified by cpu_mask
 
void WaitUntilIdle ()
 blocks until thread is idle
 
void TerminateUnit ()
 terminates thread work loop, empties queue, and joins thread.
 
void AddToQueue (Task *t)
 add this task to the task queue and return. Tasks are executed asynchronously in a strict FIFO order.
 
void NudgeThread ()
 wakes thread from idle
 

Protected Types

enum  thread_state { IDLE , EXECUTING }
 

Protected Member Functions

void ThreadLoop ()
 "semi-infinite" loop. pop task from queue and execute. if no task, go idle until new task is added.
 
void setCpuMask (size_t cpu_mask)
 bind thread to the cpu-cores specified by cpu_mask
 

Protected Attributes

bool m_stay_in_loop
 
std::thread m_thread
 
std::condition_variable m_internal_barrier
 
std::condition_variable m_external_barrier
 
std::mutex m_mutex
 
mutex_queue m_queue
 
enum CoRiBoDynamics::CoreBoundThreadPool::WorkUnit::thread_state m_state
 

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