Termination condition with lazy evaluation. This is just as a regular termination condition, except the condition is actually evaluated by computeEval() and the return value is stored in evalValue_. Every time eval() is called, evalValue_ is returned instead of actually evaluating the termination condition. Furthermore, the termination condition is evaluated every period_ seconds in a separate thread. The thread automatically starts when the condition is constructed and it terminates when the condition becomes true. More...
#include <PlannerTerminationCondition.h>
Public Member Functions | |
PlannerThreadedTerminationCondition (const PlannerTerminationConditionFn &fn, double period) | |
Construct a termination condition that is evaluated every period seconds. The evaluation of the condition (the call to computeEval()) consists of calling fn(). | |
virtual bool | eval (void) const |
Simply return the cached value for the termination condition (evalValue_) | |
![]() | |
PlannerTerminationCondition (const PlannerTerminationConditionFn &fn=PlannerTerminationConditionFn()) | |
Construct a termination condition. By default, eval() will call the externally specified function fn to decide whether the planner should terminate. The function fn does not always need to be specified, if a different implementation of eval() is provided by a derived class. | |
bool | operator() (void) const |
Return true if the planner should stop its computation. | |
operator bool () const | |
Cast as true if the planner should stop its computation. | |
void | terminate (void) const |
Notify that the condition for termination should become true, regardless of what eval() returns. This function may be called while the condition is being evaluated by other threads. | |
Protected Member Functions | |
bool | computeEval (void) |
Evaluate the termination condition. By default this is a call to fn_() from the base class. | |
void | startEvalThread (void) |
Start the thread evaluating termination conditions if not already started. | |
void | stopEvalThread (void) |
Stop the thread evaluating termination conditions if not already stopped. | |
void | periodicEval (void) |
Worker function that runs in a separate thread (calls computeEval()) | |
Protected Attributes | |
boost::thread * | thread_ |
Thread for periodicEval() | |
bool | evalValue_ |
Cached value returned by computeEval() | |
double | period_ |
Interval of time (seconds) to wait between calls to computeEval() | |
![]() | |
PlannerTerminationConditionFn | fn_ |
Function pointer to the piece of code that decides whether a termination condition has been met. | |
bool | terminate_ |
Flag indicating whether the user has externally requested that the condition for termination should become true. | |
Termination condition with lazy evaluation. This is just as a regular termination condition, except the condition is actually evaluated by computeEval() and the return value is stored in evalValue_. Every time eval() is called, evalValue_ is returned instead of actually evaluating the termination condition. Furthermore, the termination condition is evaluated every period_ seconds in a separate thread. The thread automatically starts when the condition is constructed and it terminates when the condition becomes true.
Definition at line 117 of file PlannerTerminationCondition.h.