MADARA  3.1.8
madara::knowledge::TimedExecutor Class Reference

This class executes expression events at specified times. More...

#include <TimedExecutor.h>

Collaboration diagram for madara::knowledge::TimedExecutor:

Public Member Functions

 TimedExecutor ()
 Default constructor. More...
 
 ~TimedExecutor ()
 Destructor. More...
 
void add (const TimedEvent &new_event)
 Adds a timed event to the queue. More...
 
void add (const Event &new_event)
 Adds an event to the queue. More...
 
void clear_queue (void)
 Clears the event queue. More...
 
void enter_barrier (void)
 Enters the barrier. More...
 
bool is_shutdown (void)
 Checks if the thread pool has been shutdown. More...
 
void launch_threads (unsigned int threads)
 Launches threads. More...
 
knowledge::KnowledgeRecord::Integer num_threads (void)
 Returns the number of threads. More...
 
ACE_Time_Value remove (TimedEvent &cur_event)
 Removes a timed event from the queue. More...
 
void shutdown (void)
 Informs threads of a shutdown and waits for threads to exit. More...
 
ACE_Time_Value time_until_next (void)
 Returns the time. More...
 

Private Types

typedef std::priority_queue< TimedEvent, std::vector< TimedEvent > > PriorityQueue
 guard for access and changes More...
 

Private Member Functions

void lock (void)
 Locks the context. More...
 
void unlock (void)
 Unlocks the event queue. More...
 

Private Attributes

KnowledgeBase control_plane_
 For barrier and other information. More...
 
PriorityQueue events_
 Event queue. More...
 
MADARA_LOCK_TYPE mutex_
 Mutex for local changes. More...
 
knowledge::KnowledgeRecord::Integer num_threads_
 Number of thread. More...
 
VariableReference queue_size_
 Reference to queue size in the control plane. More...
 
VariableReference terminated_
 Reference to terminated condition within control plane. More...
 
TimedEventThreadInfothread_info_
 Vector of thread info. More...
 
TimedEventThread ** threads_
 Timed Event Threads. More...
 
VariableReference threads_ref_
 Reference to the number of threads in the control plane. More...
 

Detailed Description

This class executes expression events at specified times.

Definition at line 77 of file TimedExecutor.h.

Member Typedef Documentation

typedef std::priority_queue<TimedEvent, std::vector <TimedEvent> > madara::knowledge::TimedExecutor::PriorityQueue
private

guard for access and changes

priority queue typedef

Definition at line 160 of file TimedExecutor.h.

Constructor & Destructor Documentation

madara::knowledge::TimedExecutor::TimedExecutor ( )

Default constructor.

Definition at line 14 of file TimedExecutor.cpp.

madara::knowledge::TimedExecutor::~TimedExecutor ( )

Destructor.

Definition at line 23 of file TimedExecutor.cpp.

Member Function Documentation

void madara::knowledge::TimedExecutor::add ( const TimedEvent new_event)

Adds a timed event to the queue.

Parameters
new_eventnew event to add to the queue

Definition at line 30 of file TimedExecutor.cpp.

void madara::knowledge::TimedExecutor::add ( const Event new_event)

Adds an event to the queue.

Parameters
new_eventnew event to add to the queue.

Definition at line 42 of file TimedExecutor.cpp.

void madara::knowledge::TimedExecutor::clear_queue ( void  )

Clears the event queue.

Note that this only clears the queue. If there are events currently being processed in timed event threads, they may be added to the queue once they are completed. Consequently, clear_queue is usually only completely effective if shutdown has been called previously.

Definition at line 261 of file TimedExecutor.cpp.

void madara::knowledge::TimedExecutor::enter_barrier ( void  )

Enters the barrier.

Definition at line 238 of file TimedExecutor.cpp.

bool madara::knowledge::TimedExecutor::is_shutdown ( void  )

Checks if the thread pool has been shutdown.

Returns
true if shutdown has been called. False otherwise.

Definition at line 160 of file TimedExecutor.cpp.

void madara::knowledge::TimedExecutor::launch_threads ( unsigned int  threads)

Launches threads.

Parameters
threadsnumber of threads

Definition at line 166 of file TimedExecutor.cpp.

void madara::knowledge::TimedExecutor::lock ( void  )
private

Locks the context.

Definition at line 205 of file TimedExecutor.cpp.

madara::knowledge::KnowledgeRecord::Integer madara::knowledge::TimedExecutor::num_threads ( void  )

Returns the number of threads.

Returns
the number of threads currently running

Definition at line 274 of file TimedExecutor.cpp.

ACE_Time_Value madara::knowledge::TimedExecutor::remove ( TimedEvent cur_event)

Removes a timed event from the queue.

Parameters
cur_eventa placeholder for the current highest priority event
Returns
time until next event time out (useful when the cur_event has a zeroed event (the 2nd part of the cur_event pair)

Definition at line 64 of file TimedExecutor.cpp.

void madara::knowledge::TimedExecutor::shutdown ( void  )

Informs threads of a shutdown and waits for threads to exit.

Definition at line 131 of file TimedExecutor.cpp.

ACE_Time_Value madara::knowledge::TimedExecutor::time_until_next ( void  )

Returns the time.

Definition at line 192 of file TimedExecutor.cpp.

void madara::knowledge::TimedExecutor::unlock ( void  )
private

Unlocks the event queue.

Definition at line 211 of file TimedExecutor.cpp.

Member Data Documentation

KnowledgeBase madara::knowledge::TimedExecutor::control_plane_
private

For barrier and other information.

Definition at line 200 of file TimedExecutor.h.

PriorityQueue madara::knowledge::TimedExecutor::events_
private

Event queue.

Definition at line 180 of file TimedExecutor.h.

MADARA_LOCK_TYPE madara::knowledge::TimedExecutor::mutex_
mutableprivate

Mutex for local changes.

Definition at line 175 of file TimedExecutor.h.

knowledge::KnowledgeRecord::Integer madara::knowledge::TimedExecutor::num_threads_
private

Number of thread.

Definition at line 195 of file TimedExecutor.h.

VariableReference madara::knowledge::TimedExecutor::queue_size_
private

Reference to queue size in the control plane.

Definition at line 210 of file TimedExecutor.h.

VariableReference madara::knowledge::TimedExecutor::terminated_
private

Reference to terminated condition within control plane.

Definition at line 215 of file TimedExecutor.h.

TimedEventThreadInfo* madara::knowledge::TimedExecutor::thread_info_
private

Vector of thread info.

Definition at line 185 of file TimedExecutor.h.

TimedEventThread** madara::knowledge::TimedExecutor::threads_
private

Timed Event Threads.

Definition at line 190 of file TimedExecutor.h.

VariableReference madara::knowledge::TimedExecutor::threads_ref_
private

Reference to the number of threads in the control plane.

Definition at line 205 of file TimedExecutor.h.


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