2 #ifndef _MADARA_TIMED_EXECUTOR_H_ 3 #define _MADARA_TIMED_EXECUTOR_H_ 10 #include "madara/LockType.h" 15 #include "ace/High_Res_Timer.h" 16 #include "ace/Barrier.h" 17 #include "ace/Mutex.h" 18 #include "ace/Thread_Mutex.h" 44 #ifndef _MADARA_NO_KARL_ 47 #endif // _MADARA_NO_KARL_ 71 typedef std::pair <ACE_Time_Value, Event *>
TimedEvent;
94 void add (
const TimedEvent & new_event);
100 void add (
const Event & new_event);
108 ACE_Time_Value
remove (TimedEvent & cur_event);
113 void shutdown (
void);
119 bool is_shutdown (
void);
124 ACE_Time_Value time_until_next (
void);
130 void launch_threads (
unsigned int threads);
135 void enter_barrier (
void);
144 void clear_queue (
void);
159 typedef std::priority_queue <TimedEvent, std::vector <TimedEvent> >
270 #endif // _MADARA_TIMED_EXECUTOR_H_ MADARA_Export Event fill_event(KnowledgeBase &knowledge, const std::string &expression, double delay=0.0, double period=0.0, int executions=-1)
Fills an event struct.
This class executes expression events at specified times.
std::priority_queue< TimedEvent, std::vector< TimedEvent > > PriorityQueue
guard for access and changes
VariableReference queue_size_
Reference to queue size in the control plane.
MADARA_LOCK_TYPE mutex_
Mutex for local changes.
std::pair< ACE_Time_Value, Event * > TimedEvent
unsigned int id
thread identifier
TimedExecutor * executor
pointer to TimedExecutor caller, which provides thread-safe callbacks for shutdown information ...
bool operator<(const madara::knowledge::TimedEvent &lhs, const madara::knowledge::TimedEvent &rhs)
Comparison for higher event priorities.
KnowledgeBase * knowledge
knowledge base for executing the expression (should be same as compiled)
TimedEventThread ** threads_
Timed Event Threads.
expression::ComponentNode * root
expression to be executed (rooted Tree)
knowledge::KnowledgeRecord::Integer num_threads_
Number of thread.
Optimized reference to a variable within the knowledge base.
Provides a quality-of-service-enabled threading library.
Expression container for timed event.
Thread executing timed events.
A struct that is passed to Timed Event Thread Executors to control job handling, shutdowns, etc.
This class provides a distributed knowledge base to users.
ACE_Time_Value delay
delay before first execution
An abstract base class defines a simple abstract implementation of an expression tree node...
PriorityQueue events_
Event queue.
VariableReference terminated_
Reference to terminated condition within control plane.
TimedEventThreadInfo * thread_info_
Vector of thread info.
VariableReference threads_ref_
Reference to the number of threads in the control plane.
KnowledgeBase * control_plane
For barrier and other information.
Provides functions and classes for the distributed knowledge base.
KnowledgeBase control_plane_
For barrier and other information.
Copyright (c) 2015 Carnegie Mellon University.
ACE_Time_Value period
time between executions in seconds
unsigned int executions
executions so far
int intended_executions
intended executions
bool cancel_on_false
cancel on false return value