Fawkes API
Fawkes Development Version
|
Thread class encapsulation of pthreads. More...
#include <>>
Inherited by AgentControlThread, AmclROSThread, AmclThread, BallPosLogThread, BBLoggerThread, BBLogReplayThread, BlackBoardSynchronizationThread, Bumblebee2Thread, ClipsAgentThread, ClipsNavGraphThread, ClipsProtobufThread, ClipsROSThread, ClipsTFThread, CLIPSThread, ClipsWebviewThread, ColliActThread, ColliThread, DepthcamSimThread, DynamixelActThread, DynamixelDriverThread, DynamixelSensorThread, EclipseAgentThread, ExampleBlackBoardThread, ExampleFinalizeNettlerThread, ExampleNetworkThread, ExampleThread, fawkes::AvahiThread, fawkes::BlackBoardNetworkHandler, fawkes::ConfigNetworkHandler, fawkes::FamThread, fawkes::FawkesMainThread, fawkes::FawkesNetworkClientRecvThread, fawkes::FawkesNetworkClientSendThread, fawkes::FawkesNetworkServerClientSendThread, fawkes::FawkesNetworkServerClientThread, fawkes::FawkesNetworkServerThread, fawkes::NetworkAcceptorThread, fawkes::NetworkNameResolverThread, fawkes::PluginNetworkHandler, fawkes::WebviewJpegStreamProducer, FawkesBeepDaemon, FestivalSynthThread, firevision::FuseClient, firevision::FuseServer, firevision::FuseServerClientThread, FliteSynthThread, FountainThread, FvAcquisitionThread, FvBaseThread, FvRetrieverThread, FvSrSavePipelineThread, GazeboNodeThread, GazsimCommThread, GazsimTimesourceThread, GossipExampleReceiverThread, GossipExampleSenderThread, GossipThread, IMUAcquisitionThread, IMUSensorThread, JacoActThread, JacoBimanualActThread, JacoBimanualGotoThread, JacoGotoThread, JacoInfoThread, JacoOpenraveBaseThread, JoystickAcquisitionThread, JoystickActThread, JoystickSensorThread, JoystickTeleOpThread, KatanaActThread, KatanaMotionThread, KatanaSensorAcquisitionThread, KatanaSensorThread, LaserAcquisitionThread, LaserClusterThread, LaserFilterThread, LaserLinesThread, LaserPointCloudThread, LaserSensorThread, LaserSimThread, LocalizationSimThread, LuaAgentContinuousExecutionThread, LuaAgentPeriodicExecutionThread, MapLaserGenThread, MongoDBThread, MongoLogBlackboardThread, MongoLogImagesThread, MongoLogLoggerThread, MongoLogPointCloudThread, MongoLogTransformsThread, MongoRRDThread, NaoQiBrokerThread, NaoQiButtonThread, NaoQiDCMThread, NaoQiDCMThread::HighFreqThread, NaoQiLedThread, NaoQiMotionThread, NaoQiSpeechSynthThread, NavGraphClustersThread, NavGraphGeneratorThread, NavGraphGeneratorVisualizationThread, NavGraphInteractiveThread, NavGraphROSPubThread, NavGraphStaticConstraintsThread, NavGraphThread, NavGraphVisualizationThread, OpenNiContextThread, OpenNiDepthThread, OpenNiHandTrackerThread, OpenNiImageThread, OpenNiPclOnlyThread, OpenNiPointCloudThread, OpenNiUserTrackerThread, OpenPRSAgentThread, OpenPRSExampleThread, OpenPRSThread, OpenRaveMessageHandlerThread, OpenRaveThread, PanTiltActThread, PanTiltSensorThread, PclViewerTransferThread, PlayerClientThread, PlayerF2PThread, PlayerPostSyncThread, PlayerTimeSyncThread, PointCloudDBMergeThread, PointCloudDBRetrieveThread, PointCloudDBROSCommThread, PointCloudDBStoreThread, ProcRRDThread, RefBoxCommThread, RobotinoActThread, RobotinoComThread, RobotinoIrPclThread, RobotinoRosJointsThread, RobotinoSensorThread, RobotinoSimThread, RobotStatePublisherThread, Roomba500Thread, Roomba500Thread::WorkerThread, RoombaJoystickThread, RoombaSensorThread, RosClockThread, ROSCmdVelThread, RosImagesThread, RosJointThread, RosLaserScanThread, RosMoveBaseThread, RosNavgraphBreakoutThread, RosNavigatorThread, ROSNodeThread, ROSOdometryThread, RosPointCloudThread, RosPosition3DThread, ROSRobotDescriptionThread, RosSkillerThread, ROSTalkerPubThread, RosTfThread, ROSWebviewThread, RRDExampleThread, RRDThread, RRDWebThread, SkillerExecutionThread, SkillerNavGraphFeature, SkillShellThread, SkillShellThread, StaticTransformsThread, TabletopObjectsThread, TabletopVisualizationThread, TfExampleThread, TimeTrackerMainLoopThread, VisLocalizationThread, WebcamSimThread, WebviewPtzCamThread, WebviewThread, XabslEngineThread, and XmlRpcThread.
Public Types | |
enum | OpMode { OPMODE_CONTINUOUS, OPMODE_WAITFORWAKEUP } |
Thread operation mode. More... | |
enum | CancelState { CANCEL_ENABLED, CANCEL_DISABLED } |
Cancel state. More... | |
Public Member Functions | |
virtual | ~Thread () |
Virtual destructor. More... | |
virtual void | init () |
Initialize the thread. More... | |
bool | prepare_finalize () |
Prepare finalization. More... | |
virtual bool | prepare_finalize_user () |
Prepare finalization user implementation. More... | |
virtual void | finalize () |
Finalize the thread. More... | |
void | cancel_finalize () |
Cancel finalization. More... | |
void | start (bool wait=true) |
Call this method to start the thread. More... | |
void | cancel () |
Cancel a thread. More... | |
void | join () |
Join the thread. More... | |
void | detach () |
Detach the thread. More... | |
void | kill (int sig) |
Send signal to a thread. More... | |
bool | operator== (const Thread &thread) |
Check if two threads are the same. More... | |
void | wakeup () |
Wake up thread. More... | |
void | wakeup (Barrier *barrier) |
Wake up thread and wait for barrier afterwards. More... | |
void | wait_loop_done () |
Wait for the current loop iteration to finish. More... | |
OpMode | opmode () const |
Get operation mode. More... | |
pthread_t | thread_id () const |
Get ID of thread. More... | |
bool | started () const |
Check if thread has been started. More... | |
bool | cancelled () const |
Check if thread has been cancelled. More... | |
bool | detached () const |
Check if thread has been detached. More... | |
bool | running () const |
Check if the thread is running. More... | |
bool | waiting () const |
Check if thread is currently waiting for wakeup. More... | |
const char * | name () const |
Get name of thread. More... | |
void | set_flags (uint32_t flags) |
Set all flags in one go. More... | |
void | set_flag (uint32_t flag) |
Set flag for the thread. More... | |
void | unset_flag (uint32_t flag) |
Unset flag. More... | |
bool | flagged_bad () const |
Check if FLAG_BAD was set. More... | |
void | set_delete_on_exit (bool del) |
Set whether the thread should be deleted on exit. More... | |
void | set_prepfin_hold (bool hold) |
Hold prepare_finalize(). More... | |
void | add_notification_listener (ThreadNotificationListener *notification_listener) |
Add notification listener. More... | |
void | remove_notification_listener (ThreadNotificationListener *notification_listener) |
Remove notification listener. More... | |
void | notify_of_failed_init () |
Notify of failed init. More... | |
Static Public Member Functions | |
static Thread * | current_thread () |
Get the Thread instance of the currently running thread. More... | |
static Thread * | current_thread_noexc () throw () |
Similar to current_thread, but does never throw an exception. More... | |
static pthread_t | current_thread_id () |
Get the ID of the currently running thread. More... | |
static void | init_main () |
Initialize Thread wrapper instance for main thread. More... | |
static void | destroy_main () |
Destroy main thread wrapper instance. More... | |
static void | set_cancel_state (CancelState new_state, CancelState *old_state=0) |
Set the cancel state of the current thread. More... | |
Static Public Attributes | |
static const unsigned int | FLAG_BAD = 0x00000001 |
Standard thread flag: "thread is bad". More... | |
Protected Member Functions | |
Thread (const char *name) | |
Constructor. More... | |
Thread (const char *name, OpMode op_mode) | |
Constructor. More... | |
void | exit () |
Exit the thread. More... | |
void | test_cancel () |
Set cancellation point. More... | |
void | yield () |
Yield the processor to another thread or process. More... | |
virtual void | run () |
Code to execute in the thread. More... | |
void | set_opmode (OpMode op_mode) |
Set operation mode. More... | |
void | set_prepfin_conc_loop (bool concurrent=true) |
Set concurrent execution of prepare_finalize() and loop(). More... | |
void | set_coalesce_wakeups (bool coalesce=true) |
Set wakeup coalescing. More... | |
void | set_name (const char *format,...) |
Set name of thread. More... | |
virtual void | once () |
Execute an action exactly once. More... | |
virtual void | loop () |
Code to execute in the thread. More... | |
bool | wakeup_pending () |
Check if wakeups are pending. More... | |
Protected Attributes | |
bool | finalize_prepared |
True if prepare_finalize() has been called and was not stopped with a cancel_finalize(), false otherwise. More... | |
Mutex * | loop_mutex |
Mutex that is used to protect a call to loop(). More... | |
Mutex * | loopinterrupt_antistarve_mutex |
Mutex to avoid starvation when trying to lock loop_mutex. More... | |
Friends | |
class | ThreadList |
Thread class encapsulation of pthreads.
This is the base class for all threads in Fawkes. Derive this class for your thread. Note that you have to set a meaningful name, as this name is necessary for easier debugging and it is used for internal messaging via the BlackBoard. Make sure that your name is unique throughout the software. Using the class name with an additional modifier if it is instantiated multiple times is a good bet.
The thread can operate in two modes. The loop can either run continuously without a brake, or it can wait for an explicit wakeup after each loop. Waiting for an explicit wakeup is the default since this is the common use case in Fawkes and also it is less risky, the developer will easier see that his thread does not do anything then fixing that the thread takes all CPU time.
Special care has been taken to allow for proper initialization and finalization. The special behavior of this routines can only be guaranteed if the threads are managed properly, which is the case if we speak of the Fawkes thread manager. This applies for the following paragraphs.
The thread provides an init() routine which may be implemented and is called just before the thread is started. If you make use of aspects this is the first time when you can make use of aspects. These aspects are not initialized in the constructor. init() is called just after the aspect initialization. This is also the last chance to stop the thread from being executed if you detect an error. If init() throws any exception then the thread is never started.
The methods prepare_finalize(), finalize() and cancel_finalize() are meant to be used for finalization. First prepare_finalize() is called to prepare finalization. At this stage the thread can veto and prevent finalization from happening. For this prepare_finalize_user() has to be implemented with the proper check, and maybe special actions that are needed to prepare finalization (which may or may not happen independent from the result of just this thread, see method description). Afterwards finalize() may be called (independent of the prepare_finalize() result, see method description). If finalize() is not executed the thread is notified with cancel_finalize(). Before finalize() is called the thread is stopped.
The intialization and finalization procedures may be executed deferred and concurrent to the running thread itself. The thread is only started however it init() finished successfully.
The call to prepare_finalize() is mutual exclusive with a concurrently running loop() by default. This means that if the loop() blocks waiting for some event prepare_finalize() will hang until this event happens. This can be prevented with set_prepfin_conc_loop() which allows to set that prepare_finalize() and loop() may be executed concurrently.
After prepare_finalize() has been run the thread implementation will stop the loop() from being executed. However, the thread will still run, for example it will wait for wakeup. This way it can be ensured that other threads will continue to run even this thread is currently not running. An exception is the ThreadList. For this Thread provides special synchronization features by which it is possible to stop a thread in the very same loop iteration. That means that if you have two threads that are woken up at the same time and maybe even synchronize among each other it is guaranteed that both threads will finish the running loop and never enter the next loop. Before finalize() is called the thread shall be stopped (cancelled and joined).
Because the finalization is done deferred and concurrent put all lengthy finalization routines in finalize() and avoid this in the destructor, since a long running destructor will harm the overall performance while with the surrounding framework a long-running finalize() is acceptable.
Please read the Fawkes documentation about guarantees (FawkesGuarantees in the wiki) for information about the given guarantees. Several of these guarantees are met if Thread is used in conjunction with ThreadList and the guarantees have been specifically designed for painless plugin development.
Thread operation mode.
A thread can operate in two different modes. In continuous mode the thread is on it's own running continuously. No timing is done. The loop() is immediately called again after it has finished once. In wait-for-wakeup mode the thread will pause after each loop and wait for an explicit wakeup.
Enumerator | |
---|---|
OPMODE_CONTINUOUS | operate in continuous mode (default) |
OPMODE_WAITFORWAKEUP | operate in wait-for-wakeup mode |
|
virtual |
Virtual destructor.
Definition at line 288 of file thread.cpp.
References loop_mutex, loopinterrupt_antistarve_mutex, Thread(), fawkes::WaitCondition::wake_all(), and yield().
|
protected |
Constructor.
This constructor is protected so that Thread cannot be instantiated. This constructor initalizes a few internal variables. Uses continuous operation mode.
name | thread name, used for debugging, see Thread::name() |
Definition at line 205 of file thread.cpp.
References OPMODE_CONTINUOUS.
Referenced by PanTiltDirectedPerceptionThread::bb_interface_message_received(), PanTiltSonyEviD100PThread::bb_interface_message_received(), PanTiltRX28Thread::bb_interface_message_received(), LuaAgentContinuousExecutionThread::fam_event(), init_main(), name(), NavGraphGeneratorThread::NavGraphGeneratorThread(), NavGraphThread::NavGraphThread(), Thread(), and ~Thread().
|
protected |
Constructor.
This constructor is protected so that Thread cannot be instantiated. This constructor initalizes a few internal variables.
name | thread name, used for debugging, see Thread::name() |
op_mode | Operation mode, see Thread::OpMode |
Definition at line 217 of file thread.cpp.
References finalize_prepared, loop_mutex, loopinterrupt_antistarve_mutex, name(), OPMODE_CONTINUOUS, OPMODE_WAITFORWAKEUP, and Thread().
void Thread::add_notification_listener | ( | ThreadNotificationListener * | notification_listener | ) |
Add notification listener.
Add a notification listener for this thread.
notification_listener | notification listener to add |
Definition at line 1170 of file thread.cpp.
Referenced by fawkes::MainLoopAspectIniFin::init(), name(), and FvBaseThread::register_for_camera().
void Thread::cancel | ( | ) |
Cancel a thread.
Use this to cancel the thread.
Definition at line 651 of file thread.cpp.
Referenced by Roomba500Thread::finalize(), NaoQiDCMThread::finalize(), KatanaActThread::finalize(), fawkes::ThreadManager::force_remove(), firevision::FuseImageListWidget::get_selected_image(), fawkes::ThreadManager::set_inifin(), FuseTransferWidget::set_remote_lut_list_trv(), KatanaActThread::update_sensor_values(), fawkes::ConfigNetworkHandler::~ConfigNetworkHandler(), fawkes::FawkesNetworkServerClientThread::~FawkesNetworkServerClientThread(), firevision::FuseImageListWidget::~FuseImageListWidget(), FuseTransferWidget::~FuseTransferWidget(), fawkes::LocalBlackBoard::~LocalBlackBoard(), fawkes::LuaContext::~LuaContext(), NaoFawkesModule::~NaoFawkesModule(), NetLogGuiGtkWindow::~NetLogGuiGtkWindow(), fawkes::NetworkNameResolver::~NetworkNameResolver(), fawkes::PluginManager::~PluginManager(), and fawkes::ServiceModel::~ServiceModel().
void Thread::cancel_finalize | ( | ) |
Cancel finalization.
This means that something has happened (for example another thread from the same plugin) has indicated that it can not be finalized. In that case also this thread has to continue to run and the finalization is canceled. The thread is expected to run after the finalization has been canceled as if the finalization was never tried.
This is only called on a running thread after prepare_finalization() has been called.
Definition at line 492 of file thread.cpp.
References finalize_prepared, fawkes::Mutex::lock(), loop_mutex, and fawkes::Mutex::unlock().
Referenced by fawkes::ThreadManager::set_inifin().
bool Thread::cancelled | ( | ) | const |
Check if thread has been cancelled.
Definition at line 834 of file thread.cpp.
|
static |
Get the Thread instance of the currently running thread.
This will return the Thread instance of the thread in which's context this method was called. Note that only if the main application ensures to call init_main() it can be guaranteed that this value is not NULL.
Exception | thrown if this method is called before either init_main() is called or any one thread has been started. |
Definition at line 1318 of file thread.cpp.
Referenced by destroy_main(), fawkes::RemoteBlackBoard::inbound_received(), fawkes::RemoteBlackBoard::list(), fawkes::RemoteBlackBoard::list_all(), fawkes::Spinlock::lock(), fawkes::Mutex::lock(), name(), fawkes::RemoteBlackBoard::try_aliveness_restore(), and fawkes::InterruptibleBarrier::wait().
|
static |
Get the ID of the currently running thread.
This will return the ID of the thread in which's context this method was called.
Definition at line 1302 of file thread.cpp.
Referenced by name().
|
static |
Similar to current_thread, but does never throw an exception.
This is a convenience method doing the same as current_thread(), but it never ever throws an exception, rather it returns NULL in case of an error. This is necessary if run from a C context.
Definition at line 1334 of file thread.cpp.
Referenced by fawkes::Message::Message(), and name().
|
static |
Destroy main thread wrapper instance.
This destroys the thread wrapper created with init_main(). Note that this has to be called from the very same thread that init_main() was called from, which should be the main thread (somewhere from main() on).
Definition at line 1285 of file thread.cpp.
References current_thread(), and name().
Referenced by name().
void Thread::detach | ( | ) |
Detach the thread.
Memory claimed by the thread will be automatically freed after the thread exits. You can no longer join this thread.
Definition at line 640 of file thread.cpp.
bool Thread::detached | ( | ) | const |
Check if thread has been detached.
Definition at line 844 of file thread.cpp.
|
protected |
Exit the thread.
You may call this from within your run() method to exit the thread.
Definition at line 594 of file thread.cpp.
Referenced by fawkes::FawkesMainThread::Runner::handle_signal(), fawkes::FawkesNetworkServerClientSendThread::loop(), and name().
|
virtual |
Finalize the thread.
This method is executed just before the thread is canceled and destroyed. It is always preceeded by a call to prepare_finalize(). If this is not the case this is a failure. The condition can be checked with the boolean variable finalize_prepared.
This method is meant to be used in conjunction with aspects and to cover thread inter-dependencies. This routine MUST bring the thread into a safe state such that it may be canceled and destroyed afterwards. If there is any reason that this cannot happen make your prepare_finalize() reports so.
This method is called by the thread manager just before the thread is being cancelled. Here you can do whatever steps are necessary just before the thread is cancelled. Note that you thread is still running and might be in the middle of a loop, so it is not a good place to give up on all resources used. Mind segmentation faults that could happen. Protect the area with a mutex that you lock at the beginning of your loop and free in the end, and that you lock at the beginning of finalize and then never unlock. Also not that the finalization may be canceled afterwards. The next thing that happens is that either the thread is canceled and destroyed or that the finalization is canceled and the thread has to run again.
Finalize is called on a thread just before it is deleted. It is guaranteed to be called on a fully initialized thread (if no exception is thrown in init()) (this guarantee holds in the Fawkes framework).
The default implementation does nothing besides throwing an exception if prepare_finalize() has not been called.
Exception | thrown if prepare_finalize() has not been called. |
Reimplemented in TabletopObjectsThread, RobotStatePublisherThread, AmclThread, fawkes::WebviewJpegStreamProducer, OpenRobotinoComThread, WebviewThread, LaserLinesThread, NavGraphInteractiveThread, KatanaActThread, OpenNiPointCloudThread, SkillerExecutionThread, Bumblebee2Thread, FvAcquisitionThread, ColliThread, MongoLogPointCloudThread, NavGraphThread, PlayerClientThread, LuaAgentContinuousExecutionThread, RobotinoSimThread, JacoOpenraveBaseThread, LuaAgentPeriodicExecutionThread, MongoLogImagesThread, RosTfThread, LaserClusterThread, NaoQiDCMThread, BBLoggerThread, JoystickActThread, NavGraphClustersThread, PointCloudDBROSCommThread, AmclROSThread, DynamixelDriverThread, NaoQiButtonThread, OpenNiUserTrackerThread, PanTiltRX28Thread, PointCloudDBMergeThread, RobotinoActThread, RosPointCloudThread, XabslEngineThread, BBLogReplayThread, FvBaseThread, RosSkillerThread, XmlRpcThread, ColliActThread, ClipsAgentThread, LaserFilterThread, OpenNiDepthThread, OpenNiImageThread, OpenNiPclOnlyThread, OpenPRSThread, PointCloudDBRetrieveThread, RosLaserScanThread, RosMoveBaseThread, CLIPSThread, LaserPointCloudThread, NaoQiLedThread, NaoQiMotionThread, DirectRobotinoComThread, DepthcamSimThread, LocalizationSimThread, VisLocalizationThread, OpenNiContextThread, RobotinoSensorThread, BlackBoardSynchronizationThread, WebcamSimThread, GazeboNodeThread, NaoQiSpeechSynthThread, NavGraphGeneratorThread, RosImagesThread, MapLaserGenThread, LaserSimThread, IMUAcquisitionThread, MongoLogTransformsThread, OpenNiHandTrackerThread, PointCloudDBStoreThread, FvRetrieverThread, RefBoxCommThread, Roomba500Thread, ROSNodeThread, ROSWebviewThread, ClipsNavGraphThread, MongoLogBlackboardThread, RosNavigatorThread, RosPosition3DThread, GazsimCommThread, GazsimTimesourceThread, JoystickAcquisitionThread, MongoDBThread, RobotinoIrPclThread, FliteSynthThread, LaserSensorThread, MongoLogLoggerThread, PanTiltSonyEviD100PThread, RosJointThread, StaticTransformsThread, WebviewPtzCamThread, JoystickTeleOpThread, MongoRRDThread, PanTiltDirectedPerceptionThread, TabletopVisualizationThread, RosNavgraphBreakoutThread, ClipsProtobufThread, ClipsROSThread, EclipseAgentThread, TfExampleThread, FestivalSynthThread, CruizCoreXG1010AcquisitionThread, IMUSensorThread, HokuyoUrgGbxAcquisitionThread, NavGraphROSPubThread, NavGraphStaticConstraintsThread, FountainThread, RobotinoRosJointsThread, ROSCmdVelThread, JacoGotoThread, OpenRaveMessageHandlerThread, OpenRaveThread, ProcRRDThread, ROSOdometryThread, TimeTrackerMainLoopThread, ClipsWebviewThread, AgentControlThread, JacoInfoThread, NavGraphVisualizationThread, RoombaJoystickThread, ROSTalkerPubThread, RRDThread, BallPosLogThread, GossipExampleSenderThread, GossipThread, JoystickSensorThread, NaoQiBrokerThread, FvSrSavePipelineThread, RosClockThread, RRDWebThread, JacoActThread, JacoBimanualActThread, HokuyoUrgAcquisitionThread, NavGraphGeneratorVisualizationThread, OpenPRSAgentThread, ClipsTFThread, JacoBimanualGotoThread, GossipExampleReceiverThread, ExampleBlackBoardThread, LaseEdlAcquisitionThread, OpenPRSExampleThread, RRDExampleThread, SkillerNavGraphFeature, ExampleFinalizeNettlerThread, ExampleNetworkThread, ExampleThread, ROSRobotDescriptionThread, JacoOpenraveThread, SickTiM55xEthernetAcquisitionThread, SickTiM55xUSBAcquisitionThread, PlayerTimeSyncThread, JacoBimanualOpenraveThread, PlayerF2PThread, and PlayerPostSyncThread.
Definition at line 473 of file thread.cpp.
Referenced by KatanaActThread::finalize(), fawkes::ThreadManager::force_remove(), and fawkes::ThreadManager::set_inifin().
bool Thread::flagged_bad | ( | ) | const |
Check if FLAG_BAD was set.
This is a convenience method to check if FLAG_BAD has been set.
Definition at line 1159 of file thread.cpp.
References FLAG_BAD.
Referenced by name().
|
virtual |
Initialize the thread.
This method is meant to be used in conjunction with aspects. Some parts of the initialization may only happen after some aspect of the thread has been initialized. Implement the init method with these actions. It is guaranteed to be called just after all aspects have been initialized and only once in the lifetime of the thread. Throw an exception if any problem occurs and the thread should not run.
Just because your init() routine suceeds and everything looks fine for this thread does not automatically imply that it will run. If it belongs to a group of threads in a ThreadList and any of the other threads fail to initialize then no thread from this group is run and thus this thread will never run. In that situation finalize() is called for this very instance, prepare_finalize() however is not called.
Reimplemented in TabletopObjectsThread, RobotStatePublisherThread, AmclThread, fawkes::WebviewJpegStreamProducer, WebviewThread, OpenRobotinoComThread, LaserLinesThread, NavGraphInteractiveThread, KatanaActThread, OpenNiPointCloudThread, SkillerExecutionThread, Bumblebee2Thread, FvAcquisitionThread, ColliThread, PlayerClientThread, MongoLogPointCloudThread, LuaAgentContinuousExecutionThread, NavGraphThread, RobotinoSimThread, JacoOpenraveBaseThread, LuaAgentPeriodicExecutionThread, RosTfThread, BBLoggerThread, JoystickActThread, LaserClusterThread, MongoLogImagesThread, NaoQiDCMThread, DynamixelDriverThread, NavGraphClustersThread, PointCloudDBROSCommThread, XabslEngineThread, AmclROSThread, BBLogReplayThread, NaoQiButtonThread, OpenNiUserTrackerThread, PanTiltRX28Thread, PointCloudDBMergeThread, RosPointCloudThread, RosSkillerThread, XmlRpcThread, FvBaseThread, RobotinoActThread, ColliActThread, LaserFilterThread, RosMoveBaseThread, ClipsAgentThread, OpenNiDepthThread, OpenNiImageThread, OpenNiPclOnlyThread, OpenPRSThread, PointCloudDBRetrieveThread, RosLaserScanThread, CLIPSThread, LaserPointCloudThread, NaoQiLedThread, NaoQiMotionThread, DepthcamSimThread, LocalizationSimThread, VisLocalizationThread, OpenNiContextThread, RobotinoSensorThread, BlackBoardSynchronizationThread, WebcamSimThread, GazeboNodeThread, NaoQiSpeechSynthThread, NavGraphGeneratorThread, FvRetrieverThread, RefBoxCommThread, Roomba500Thread, RosImagesThread, MapLaserGenThread, LaserSimThread, IMUAcquisitionThread, OpenNiHandTrackerThread, PointCloudDBStoreThread, DirectRobotinoComThread, RosNavigatorThread, ROSNodeThread, RosPosition3DThread, ROSWebviewThread, ClipsNavGraphThread, JoystickAcquisitionThread, MongoLogBlackboardThread, MongoLogTransformsThread, FliteSynthThread, GazsimCommThread, GazsimTimesourceThread, LaserSensorThread, MongoDBThread, PanTiltSonyEviD100PThread, RobotinoIrPclThread, RosJointThread, MongoLogLoggerThread, PanTiltDirectedPerceptionThread, RosNavgraphBreakoutThread, StaticTransformsThread, WebviewPtzCamThread, EclipseAgentThread, FestivalSynthThread, CruizCoreXG1010AcquisitionThread, IMUSensorThread, HokuyoUrgGbxAcquisitionThread, MongoRRDThread, FountainThread, TabletopVisualizationThread, ClipsProtobufThread, ClipsROSThread, TfExampleThread, JacoGotoThread, JoystickTeleOpThread, NavGraphROSPubThread, NavGraphStaticConstraintsThread, RobotinoRosJointsThread, JacoInfoThread, OpenRaveMessageHandlerThread, OpenRaveThread, ProcRRDThread, RoombaJoystickThread, ROSCmdVelThread, ROSOdometryThread, TimeTrackerMainLoopThread, ClipsWebviewThread, AgentControlThread, JoystickSensorThread, NavGraphVisualizationThread, FvSrSavePipelineThread, ROSTalkerPubThread, RRDThread, BallPosLogThread, GossipExampleSenderThread, GossipThread, JacoActThread, JacoBimanualActThread, HokuyoUrgAcquisitionThread, NaoQiBrokerThread, RosClockThread, RRDWebThread, ExampleBlackBoardThread, JacoBimanualGotoThread, NavGraphGeneratorVisualizationThread, OpenPRSAgentThread, ClipsTFThread, GossipExampleReceiverThread, LaseEdlAcquisitionThread, OpenPRSExampleThread, ExampleNetworkThread, ROSRobotDescriptionThread, RRDExampleThread, SkillerNavGraphFeature, ExampleThread, SickTiM55xEthernetAcquisitionThread, SickTiM55xUSBAcquisitionThread, PlayerTimeSyncThread, ExampleFinalizeNettlerThread, PlayerF2PThread, and PlayerPostSyncThread.
Definition at line 350 of file thread.cpp.
Referenced by fawkes::ThreadManager::set_inifin().
|
static |
void Thread::join | ( | ) |
Join the thread.
This waites for the thread to exit.
Definition at line 610 of file thread.cpp.
References loop_mutex, fawkes::Mutex::try_lock(), and fawkes::Mutex::unlock().
Referenced by JoystickBlackBoardActListener::bb_interface_message_received(), SkillShellThread::connection_established(), Roomba500Thread::finalize(), NaoQiDCMThread::finalize(), KatanaActThread::finalize(), fawkes::ThreadManager::force_remove(), firevision::FuseImageListWidget::get_selected_image(), FawkesBeepDaemon::handle_signal(), KatanaActThread::loop(), fawkes::ThreadManager::set_inifin(), FuseTransferWidget::set_remote_lut_list_trv(), KatanaActThread::update_sensor_values(), fawkes::ConfigNetworkHandler::~ConfigNetworkHandler(), fawkes::FawkesNetworkServerClientThread::~FawkesNetworkServerClientThread(), firevision::FuseImageListWidget::~FuseImageListWidget(), FuseTransferWidget::~FuseTransferWidget(), fawkes::LocalBlackBoard::~LocalBlackBoard(), fawkes::LuaContext::~LuaContext(), NaoFawkesModule::~NaoFawkesModule(), NetLogGuiGtkWindow::~NetLogGuiGtkWindow(), fawkes::NetworkNameResolver::~NetworkNameResolver(), and fawkes::PluginManager::~PluginManager().
void Thread::kill | ( | int | sig | ) |
Send signal to a thread.
Not that sending an unhandled signal might kill the whole process, not just the thread!
sig | signal to send. |
Definition at line 668 of file thread.cpp.
Referenced by OpenNiContextThread::loop().
|
protectedvirtual |
Code to execute in the thread.
Implement this method to hold the code you want to be executed continously. If you do not implement this method, the default is that the thread will exit. This is useful if you choose to only implement once().
Reimplemented in fawkes::FawkesNetworkClientRecvThread, NaoQiDCMThread::HighFreqThread, TabletopObjectsThread, SkillShellThread, RobotStatePublisherThread, SkillShellThread, fawkes::FawkesNetworkClientSendThread, AmclThread, fawkes::WebviewJpegStreamProducer, WebviewThread, OpenRobotinoComThread, fawkes::FawkesNetworkServerClientSendThread, KatanaActThread, LaserLinesThread, NavGraphInteractiveThread, Roomba500Thread::WorkerThread, OpenNiPointCloudThread, SkillerExecutionThread, Bumblebee2Thread, FvAcquisitionThread, fawkes::FawkesMainThread, fawkes::NetworkNameResolverThread, PlayerClientThread, ColliThread, MongoLogPointCloudThread, NavGraphThread, LuaAgentContinuousExecutionThread, RobotinoSimThread, fawkes::PluginNetworkHandler, LuaAgentPeriodicExecutionThread, FawkesBeepDaemon, BBLoggerThread, JoystickActThread, RosTfThread, XabslEngineThread, fawkes::AvahiThread, DynamixelDriverThread, LaserClusterThread, MongoLogImagesThread, NaoQiDCMThread, PanTiltRX28Thread, RosSkillerThread, BBLogReplayThread, NavGraphClustersThread, PointCloudDBROSCommThread, XmlRpcThread, firevision::FuseClient, AmclROSThread, NaoQiButtonThread, OpenNiUserTrackerThread, PointCloudDBMergeThread, RobotinoActThread, RosMoveBaseThread, RosPointCloudThread, LaserFilterThread, FvBaseThread, ColliActThread, fawkes::ConfigNetworkHandler, firevision::FuseServer, ClipsAgentThread, OpenNiDepthThread, OpenNiImageThread, OpenNiPclOnlyThread, OpenPRSThread, PointCloudDBRetrieveThread, RosLaserScanThread, CLIPSThread, LaserPointCloudThread, NaoQiLedThread, NaoQiMotionThread, fawkes::BlackBoardNetworkHandler, fawkes::FawkesNetworkServerThread, DepthcamSimThread, LocalizationSimThread, VisLocalizationThread, OpenNiContextThread, FvRetrieverThread, RefBoxCommThread, RobotinoSensorThread, Roomba500Thread, BlackBoardSynchronizationThread, WebcamSimThread, GazeboNodeThread, NaoQiSpeechSynthThread, NavGraphGeneratorThread, DirectRobotinoComThread, RosImagesThread, RosNavigatorThread, firevision::FuseServerClientThread, MapLaserGenThread, LaserSimThread, IMUAcquisitionThread, JoystickAcquisitionThread, MongoLogTransformsThread, OpenNiHandTrackerThread, PointCloudDBStoreThread, ROSNodeThread, ROSWebviewThread, ClipsNavGraphThread, FliteSynthThread, LaserSensorThread, MongoLogBlackboardThread, PanTiltSonyEviD100PThread, FestivalSynthThread, GazsimCommThread, GazsimTimesourceThread, MongoDBThread, PanTiltDirectedPerceptionThread, RobotinoIrPclThread, RosNavgraphBreakoutThread, fawkes::NetworkAcceptorThread, CruizCoreXG1010AcquisitionThread, IMUSensorThread, HokuyoUrgGbxAcquisitionThread, MongoLogLoggerThread, FountainThread, StaticTransformsThread, WebviewPtzCamThread, JacoGotoThread, MongoRRDThread, TabletopVisualizationThread, ClipsProtobufThread, ClipsROSThread, AgentControlThread, TfExampleThread, JacoInfoThread, JoystickTeleOpThread, NavGraphROSPubThread, NavGraphStaticConstraintsThread, RobotinoRosJointsThread, RoombaJoystickThread, JoystickSensorThread, KatanaSensorThread, OpenRaveMessageHandlerThread, OpenRaveThread, FvSrSavePipelineThread, ProcRRDThread, ROSCmdVelThread, ROSOdometryThread, TimeTrackerMainLoopThread, ClipsWebviewThread, JacoActThread, JacoBimanualActThread, HokuyoUrgAcquisitionThread, NavGraphVisualizationThread, ROSTalkerPubThread, RRDThread, BallPosLogThread, GossipExampleSenderThread, GossipThread, JacoBimanualGotoThread, NaoQiBrokerThread, RosClockThread, RRDWebThread, fawkes::FawkesNetworkServerClientThread, ExampleBlackBoardThread, NavGraphGeneratorVisualizationThread, OpenPRSAgentThread, PanTiltSensorThread, ClipsTFThread, LaseEdlAcquisitionThread, GossipExampleReceiverThread, ExampleNetworkThread, OpenPRSExampleThread, RRDExampleThread, SkillerNavGraphFeature, fawkes::FamThread, DynamixelSensorThread, ExampleThread, SickTiM55xEthernetAcquisitionThread, SickTiM55xUSBAcquisitionThread, PclViewerTransferThread, PlayerTimeSyncThread, JacoOpenraveThread, KatanaSensorAcquisitionThread, DynamixelActThread, ExampleFinalizeNettlerThread, PlayerF2PThread, RoombaSensorThread, JacoBimanualOpenraveThread, and PlayerPostSyncThread.
Definition at line 1068 of file thread.cpp.
References loop_mutex, and fawkes::Mutex::unlock().
|
inline |
Get name of thread.
This name is mainly used for debugging purposes. Give it a descriptive name. Is nothing is given the raw class name is used.
Definition at line 95 of file thread.h.
References add_notification_listener(), current_thread(), current_thread_id(), current_thread_noexc(), destroy_main(), exit(), flagged_bad(), init_main(), loop(), notify_of_failed_init(), once(), remove_notification_listener(), run(), set_cancel_state(), set_coalesce_wakeups(), set_delete_on_exit(), set_flag(), set_flags(), set_name(), set_opmode(), set_prepfin_conc_loop(), set_prepfin_hold(), test_cancel(), Thread(), unset_flag(), wakeup_pending(), and yield().
Referenced by PclViewerTransferThread::add_camera(), JacoOpenraveThread::add_target(), RosJointThread::bb_interface_created(), RosPosition3DThread::bb_interface_created(), MongoLogBlackboardThread::bb_interface_created(), LaserPointCloudThread::bb_interface_created(), RosLaserScanThread::bb_interface_created(), RosTfThread::bb_interface_created(), RobotStatePublisherThread::bb_interface_created(), BBLoggerThread::bb_interface_data_changed(), PanTiltDirectedPerceptionThread::bb_interface_message_received(), PanTiltSonyEviD100PThread::bb_interface_message_received(), BBLoggerThread::bb_interface_message_received(), DynamixelDriverThread::bb_interface_message_received(), PanTiltRX28Thread::bb_interface_message_received(), KatanaActThread::bb_interface_message_received(), LaserPointCloudThread::bb_interface_reader_removed(), RosLaserScanThread::bb_interface_reader_removed(), RosTfThread::bb_interface_reader_removed(), BBLoggerThread::bb_interface_writer_removed(), OpenNiUserTrackerThread::calibration_end(), OpenNiUserTrackerThread::calibration_start(), ClipsTFThread::clips_context_destroyed(), ClipsProtobufThread::clips_context_destroyed(), ClipsNavGraphThread::clips_context_destroyed(), ClipsTFThread::clips_context_init(), ClipsProtobufThread::clips_context_init(), ClipsNavGraphThread::clips_context_init(), destroy_main(), DynamixelDriverThread::exec_act(), DynamixelDriverThread::exec_sensor(), LuaAgentContinuousExecutionThread::fam_event(), NavGraphThread::fam_event(), fawkes::FawkesMainThread::FawkesMainThread(), fawkes::ROSAspectIniFin::finalize(), SickTiM55xUSBAcquisitionThread::finalize(), fawkes::BlackBoardAspectIniFin::finalize(), fawkes::VisionAspectIniFin::finalize(), fawkes::AspectProviderAspectIniFin::finalize(), fawkes::WebviewAspectIniFin::finalize(), ExampleThread::finalize(), fawkes::NavGraphAspectIniFin::finalize(), fawkes::LoggerAspectIniFin::finalize(), fawkes::TimeSourceAspectIniFin::finalize(), fawkes::MongoDBAspectIniFin::finalize(), fawkes::GazeboAspectIniFin::finalize(), fawkes::GossipAspectIniFin::finalize(), fawkes::TransformAspectIniFin::finalize(), ExampleBlackBoardThread::finalize(), fawkes::CLIPSFeatureAspectIniFin::finalize(), fawkes::CLIPSManagerAspectIniFin::finalize(), fawkes::VisionMasterAspectIniFin::finalize(), fawkes::OpenPRSManagerAspectIniFin::finalize(), JacoBimanualActThread::finalize(), fawkes::CLIPSAspectIniFin::finalize(), HokuyoUrgAcquisitionThread::finalize(), JacoActThread::finalize(), fawkes::MainLoopAspectIniFin::finalize(), fawkes::OpenPRSAspectIniFin::finalize(), ProcRRDThread::finalize(), OpenRaveMessageHandlerThread::finalize(), ROSCmdVelThread::finalize(), HokuyoUrgGbxAcquisitionThread::finalize(), RosNavgraphBreakoutThread::finalize(), JoystickTeleOpThread::finalize(), MongoRRDThread::finalize(), StaticTransformsThread::finalize(), RosNavigatorThread::finalize(), FvRetrieverThread::finalize(), MapLaserGenThread::finalize(), RosImagesThread::finalize(), RosMoveBaseThread::finalize(), OpenPRSThread::finalize(), RosSkillerThread::finalize(), DynamixelDriverThread::finalize(), PanTiltRX28Thread::finalize(), fawkes::AspectManager::finalize(), MongoLogImagesThread::finalize(), ColliThread::finalize(), Bumblebee2Thread::finalize(), OpenNiPointCloudThread::finalize(), KatanaActThread::finalize(), SkillerNavGraphFeature::finalize_lua_context(), OpenNiHandTrackerThread::gesture_progress(), OpenNiHandTrackerThread::gesture_recognized(), NavGraphROSPubThread::graph_changed(), ClipsNavGraphThread::graph_changed(), OpenNiHandTrackerThread::hand_create(), OpenNiHandTrackerThread::hand_destroy(), OpenNiHandTrackerThread::hand_update(), fawkes::RemoteBlackBoard::inbound_received(), fawkes::BlockedTimingAspectIniFin::init(), fawkes::ROSAspectIniFin::init(), fawkes::PointCloudAspectIniFin::init(), fawkes::NaoQiAspectIniFin::init(), fawkes::OpenNiAspectIniFin::init(), fawkes::FawkesNetworkAspectIniFin::init(), fawkes::AspectProviderAspectIniFin::init(), ExampleThread::init(), fawkes::ThreadProducerAspectIniFin::init(), fawkes::VisionAspectIniFin::init(), fawkes::LoggingAspectIniFin::init(), fawkes::BlackBoardAspectIniFin::init(), fawkes::WebviewAspectIniFin::init(), fawkes::ClockAspectIniFin::init(), fawkes::ConfigurableAspectIniFin::init(), fawkes::PluginDirectorAspectIniFin::init(), fawkes::LoggerAspectIniFin::init(), fawkes::NavGraphAspectIniFin::init(), fawkes::RRDAspectIniFin::init(), fawkes::TimeSourceAspectIniFin::init(), fawkes::MongoDBAspectIniFin::init(), fawkes::GazeboAspectIniFin::init(), fawkes::OpenRaveAspectIniFin::init(), fawkes::GossipAspectIniFin::init(), fawkes::TransformAspectIniFin::init(), fawkes::NetworkAspectIniFin::init(), fawkes::CLIPSFeatureAspectIniFin::init(), fawkes::CLIPSManagerAspectIniFin::init(), fawkes::VisionMasterAspectIniFin::init(), ExampleBlackBoardThread::init(), fawkes::OpenPRSManagerAspectIniFin::init(), GossipThread::init(), fawkes::CLIPSAspectIniFin::init(), HokuyoUrgAcquisitionThread::init(), JacoActThread::init(), NaoQiBrokerThread::init(), fawkes::MainLoopAspectIniFin::init(), fawkes::OpenPRSAspectIniFin::init(), ProcRRDThread::init(), RoombaJoystickThread::init(), OpenRaveThread::init(), TimeTrackerMainLoopThread::init(), OpenRaveMessageHandlerThread::init(), ClipsProtobufThread::init(), JoystickTeleOpThread::init(), NavGraphStaticConstraintsThread::init(), HokuyoUrgGbxAcquisitionThread::init(), MongoRRDThread::init(), EclipseAgentThread::init(), RosNavgraphBreakoutThread::init(), WebviewPtzCamThread::init(), MongoDBThread::init(), JoystickAcquisitionThread::init(), MongoLogBlackboardThread::init(), MongoLogTransformsThread::init(), RosNavigatorThread::init(), MapLaserGenThread::init(), OpenNiHandTrackerThread::init(), LaserSimThread::init(), ROSNodeThread::init(), FvRetrieverThread::init(), Roomba500Thread::init(), NavGraphGeneratorThread::init(), BlackBoardSynchronizationThread::init(), WebcamSimThread::init(), GazeboNodeThread::init(), DepthcamSimThread::init(), LocalizationSimThread::init(), VisLocalizationThread::init(), ClipsAgentThread::init(), RosLaserScanThread::init(), OpenNiImageThread::init(), OpenPRSThread::init(), ColliActThread::init(), LaserFilterThread::init(), RosMoveBaseThread::init(), BBLogReplayThread::init(), RosSkillerThread::init(), NaoQiButtonThread::init(), PanTiltRX28Thread::init(), DynamixelDriverThread::init(), LaserClusterThread::init(), MongoLogImagesThread::init(), BBLoggerThread::init(), fawkes::AspectManager::init(), RobotinoSimThread::init(), NavGraphThread::init(), MongoLogPointCloudThread::init(), PlayerClientThread::init(), ColliThread::init(), FvAcquisitionThread::init(), Bumblebee2Thread::init(), OpenNiPointCloudThread::init(), KatanaActThread::init(), WebviewThread::init(), RobotStatePublisherThread::init(), TabletopObjectsThread::init(), SickTiM55xCommonAcquisitionThread::init_device(), SkillerNavGraphFeature::init_lua_context(), JacoBimanualOpenraveThread::JacoBimanualOpenraveThread(), JacoOpenraveThread::JacoOpenraveThread(), RoombaSensorThread::loop(), KatanaSensorAcquisitionThread::loop(), SickTiM55xEthernetAcquisitionThread::loop(), SickTiM55xUSBAcquisitionThread::loop(), ExampleThread::loop(), RRDExampleThread::loop(), GossipExampleReceiverThread::loop(), ClipsTFThread::loop(), OpenPRSAgentThread::loop(), PanTiltSensorThread::loop(), JacoBimanualGotoThread::loop(), GossipExampleSenderThread::loop(), JacoBimanualActThread::loop(), HokuyoUrgAcquisitionThread::loop(), JacoActThread::loop(), ProcRRDThread::loop(), FvSrSavePipelineThread::loop(), OpenRaveMessageHandlerThread::loop(), JoystickTeleOpThread::loop(), RoombaJoystickThread::loop(), JacoInfoThread::loop(), TfExampleThread::loop(), JacoGotoThread::loop(), MongoRRDThread::loop(), WebviewPtzCamThread::loop(), CruizCoreXG1010AcquisitionThread::loop(), HokuyoUrgGbxAcquisitionThread::loop(), PanTiltDirectedPerceptionThread::loop(), RosNavgraphBreakoutThread::loop(), PanTiltSonyEviD100PThread::loop(), PointCloudDBStoreThread::loop(), JoystickAcquisitionThread::loop(), MapLaserGenThread::loop(), ROSWebviewThread::loop(), MongoLogTransformsThread::loop(), DirectRobotinoComThread::loop(), NavGraphGeneratorThread::loop(), BlackBoardSynchronizationThread::loop(), RosImagesThread::loop(), RosNavigatorThread::loop(), RobotinoSensorThread::loop(), OpenNiContextThread::loop(), Roomba500Thread::loop(), NaoQiMotionThread::loop(), ClipsAgentThread::loop(), PointCloudDBRetrieveThread::loop(), RosLaserScanThread::loop(), ColliActThread::loop(), LaserFilterThread::loop(), FvBaseThread::loop(), RosMoveBaseThread::loop(), NaoQiButtonThread::loop(), RobotinoActThread::loop(), OpenNiUserTrackerThread::loop(), PointCloudDBMergeThread::loop(), RosPointCloudThread::loop(), PointCloudDBROSCommThread::loop(), NavGraphClustersThread::loop(), BBLogReplayThread::loop(), PanTiltRX28Thread::loop(), DynamixelDriverThread::loop(), RosSkillerThread::loop(), LaserClusterThread::loop(), NaoQiDCMThread::loop(), MongoLogImagesThread::loop(), XabslEngineThread::loop(), fawkes::PluginNetworkHandler::loop(), LuaAgentContinuousExecutionThread::loop(), NavGraphThread::loop(), MongoLogPointCloudThread::loop(), ColliThread::loop(), PlayerClientThread::loop(), fawkes::NetworkNameResolverThread::loop(), FvAcquisitionThread::loop(), Bumblebee2Thread::loop(), LaserLinesThread::loop(), KatanaActThread::loop(), OpenRobotinoComThread::loop(), WebviewThread::loop(), RobotStatePublisherThread::loop(), TabletopObjectsThread::loop(), OpenNiUserTrackerThread::lost_user(), fawkes::Message::Message(), JacoBimanualGotoThread::move_gripper(), OpenNiUserTrackerThread::new_user(), KatanaCalibrationThread::once(), KatanaMotorControlThread::once(), KatanaGotoThread::once(), EclipseAgentThread::once(), FestivalSynthThread::once(), RosMoveBaseThread::once(), RosSkillerThread::once(), KatanaActThread::once(), JacoBimanualOpenraveThread::plot_first(), OpenNiUserTrackerThread::pose_end(), OpenNiUserTrackerThread::pose_start(), LaseEdlAcquisitionThread::pre_init(), fawkes::AspectManager::prepare_finalize(), PanTiltRX28Thread::prepare_finalize_user(), AmclROSThread::publish_map(), LuaAgentContinuousExecutionThread::read_interfaces(), FvBaseThread::register_for_camera(), DirectRobotinoComThread::reset_odometry(), fawkes::AvahiThread::resolve_name(), FliteSynthThread::say(), DirectRobotinoComThread::set_bumper_estop_enabled(), OpenRobotinoComThread::set_bumper_estop_enabled(), DirectRobotinoComThread::set_desired_vel(), DirectRobotinoComThread::set_digital_output(), OpenRobotinoComThread::set_digital_output(), BBLoggerThread::set_enabled(), fawkes::ThreadManager::set_inifin(), DirectRobotinoComThread::set_motor_accel_limits(), DirectRobotinoComThread::set_speed_points(), JacoOpenraveThread::set_target_ang(), BBLoggerThread::set_threadlist(), FvAcquisitionThread::set_vt_prepfin_hold(), JacoGotoThread::stop(), PlayerClientThread::sync_fawkes_to_player(), Thread(), fawkes::AvahiThread::unpublish_service(), FvBaseThread::unregister_thread(), fawkes::AvahiThread::unwatch_service(), KatanaActThread::update_sensor_values(), LaserFilterThread::wait_done(), LuaAgentContinuousExecutionThread::write_interfaces(), BlackBoardSynchronizationThread::writer_added(), BlackBoardSynchronizationThread::writer_removed(), LuaAgentContinuousExecutionThread::~LuaAgentContinuousExecutionThread(), LuaAgentPeriodicExecutionThread::~LuaAgentPeriodicExecutionThread(), and NavGraphInteractiveThread::~NavGraphInteractiveThread().
void Thread::notify_of_failed_init | ( | ) |
Notify of failed init.
This method must be called if the initialization of the thread failed, e.g. in a thread collector. Do not use it arbitrarily!
Definition at line 1210 of file thread.cpp.
Referenced by name(), and fawkes::ThreadManager::set_inifin().
|
protectedvirtual |
Execute an action exactly once.
This code is executed once and only once right after the thread is started before loop() is called. This is useful if you want to implement an one-shot background job. Just implement once() and leave loop() untouched. Start the thread and detach it and it will just do its job and then die automatically. If you use set_delete_on_exit(true) even the Thread instance will be automatically deleted.
Reimplemented in fawkes::FawkesNetworkClientRecvThread, fawkes::FawkesNetworkClientSendThread, OpenRobotinoComThread, KatanaActThread, fawkes::FawkesMainThread, NavGraphThread, BBLogReplayThread, XabslEngineThread, RosSkillerThread, RobotinoActThread, RosMoveBaseThread, DirectRobotinoComThread, EclipseAgentThread, FestivalSynthThread, fawkes::FawkesNetworkServerClientThread, KatanaGripperThread, KatanaGotoThread, KatanaMotorControlThread, and KatanaCalibrationThread.
Definition at line 1087 of file thread.cpp.
bool Thread::operator== | ( | const Thread & | thread | ) |
Check if two threads are the same.
thread | Thread to compare this thread to. |
Definition at line 917 of file thread.cpp.
Thread::OpMode Thread::opmode | ( | ) | const |
Get operation mode.
Definition at line 678 of file thread.cpp.
Referenced by fawkes::BlockedTimingAspectIniFin::init(), fawkes::VisionAspectIniFin::init(), fawkes::MainLoopAspectIniFin::init(), and BBLogReplayThread::loop().
bool Thread::prepare_finalize | ( | ) |
Prepare finalization.
Check if finalization at this point is possible and if so execute the steps necessary to prepare for finalization. You also have to make sure that this state of being able to finalize does not change until either finalize() or cancel_finalize() is called.
This method may return false, which means that at this point the thread cannot be stopped safely. This might be due to a critical internal condition that may hurt hardware if turned of right now. In this case a logger should be used to log the reason for the failure. The check is implemented in prepare_finalize_user(), which the user has to implement if he needs special treatment.
Even if the finalization is said to be unsafe and false is returned, the caller may still decide to finalize this thread, for example if all threads are shut down on application exit. So you may not rely on the fact that the thread is not stopped if you return false.
You may not override this method.
It is guaranteed that this method is only called for a running thread.
Definition at line 383 of file thread.cpp.
References finalize_prepared, fawkes::Mutex::lock(), loop_mutex, loopinterrupt_antistarve_mutex, prepare_finalize_user(), fawkes::Mutex::unlock(), and fawkes::WaitCondition::wait().
Referenced by fawkes::ThreadManager::force_remove(), and fawkes::ThreadManager::set_inifin().
|
virtual |
Prepare finalization user implementation.
This method is called by prepare_finalize(). If there can ever be a situation where it is not safe to turn of a thread at some point in time then implement this method to determine these unsafe states.
An example that comes to my mind is our Katana arm. If you turn it off it looses all power and collapses back upon itself. This may damage the arm if it is not in a safe position. In this situation this method would return false to indicate this problem.
It is up to the user to decide if this should be taken for an implied signal to get in such a safe state, if this is possible at all.
This feature should be used rarely as it can have tremendous implications on the performance and experience of the whole software. In any case your implementation should somehow inform the user of the problem that caused the finalization to fail. If you are using aspect use the LoggerAspect and log the reason.
The default implementation always allows finalization.
Reimplemented in MongoLogPointCloudThread, MongoLogImagesThread, PanTiltRX28Thread, DirectRobotinoComThread, MongoLogTransformsThread, JoystickTeleOpThread, ROSCmdVelThread, AgentControlThread, and ExampleFinalizeNettlerThread.
Definition at line 433 of file thread.cpp.
Referenced by prepare_finalize().
void Thread::remove_notification_listener | ( | ThreadNotificationListener * | notification_listener | ) |
Remove notification listener.
notification_listener | notification listener to remove |
Definition at line 1180 of file thread.cpp.
Referenced by name().
|
protectedvirtual |
Code to execute in the thread.
Executes loop() in each cycle. This is the default implementation and if you need a more specific behaviour you can override this run() method and ignore loop(). Although this method is declared virtual, it should not be overridden, other than with the following trivial snippet:
The reason not to do other changes is that it contains complex house keeping code that the system relies on. The reason for still allowing the override is solely to make reading back traces in your debugger easier. Because now there the class name of the thread sub-class will appear in the back trace, while it would not otherwise.
Reimplemented in fawkes::FawkesNetworkClientRecvThread, TabletopObjectsThread, fawkes::FawkesNetworkClientSendThread, fawkes::FawkesNetworkServerClientSendThread, OpenRobotinoComThread, MongoLogLoggerThread, WebviewThread, fawkes::FawkesMainThread, IMUAcquisitionThread, LaserLinesThread, OpenRaveThread, RosTfThread, LaserClusterThread, FvAcquisitionThread, Bumblebee2Thread, LaserFilterThread, AmclThread, KatanaActThread, SkillerExecutionThread, fawkes::PluginNetworkHandler, JacoOpenraveBaseThread, fawkes::FawkesNetworkServerThread, NavGraphInteractiveThread, FvBaseThread, fawkes::AvahiThread, OpenNiPointCloudThread, PointCloudDBROSCommThread, RosLaserScanThread, LuaAgentContinuousExecutionThread, DirectRobotinoComThread, PlayerClientThread, AmclROSThread, BBLoggerThread, LaserPointCloudThread, NavGraphThread, fawkes::NetworkNameResolverThread, DynamixelDriverThread, MongoLogPointCloudThread, NavGraphClustersThread, OpenNiUserTrackerThread, PanTiltRX28Thread, RefBoxCommThread, ROSWebviewThread, JoystickAcquisitionThread, LuaAgentPeriodicExecutionThread, XabslEngineThread, MongoLogImagesThread, fawkes::ConfigNetworkHandler, JoystickActThread, NaoQiDCMThread, OpenNiHandTrackerThread, BBLogReplayThread, OpenNiContextThread, PointCloudDBMergeThread, NaoQiButtonThread, RobotinoActThread, RosPointCloudThread, XmlRpcThread, ClipsNavGraphThread, JacoGotoThread, RRDThread, GazsimCommThread, PointCloudDBRetrieveThread, PointCloudDBStoreThread, BlackBoardSynchronizationThread, ClipsAgentThread, OpenNiDepthThread, OpenNiImageThread, OpenNiPclOnlyThread, OpenPRSThread, PanTiltSonyEviD100PThread, CLIPSThread, FliteSynthThread, NaoQiLedThread, NaoQiMotionThread, PanTiltDirectedPerceptionThread, Roomba500Thread, LaserAcquisitionThread, MongoLogBlackboardThread, RobotinoSensorThread, fawkes::BlackBoardNetworkHandler, FestivalSynthThread, GazeboNodeThread, MongoDBThread, NaoQiSpeechSynthThread, NavGraphGeneratorThread, FvRetrieverThread, RosImagesThread, ClipsProtobufThread, ClipsROSThread, MongoLogTransformsThread, RosNavigatorThread, ROSNodeThread, fawkes::FawkesNetworkServerClientThread, MapLaserGenThread, LaserSensorThread, RobotinoIrPclThread, RoombaJoystickThread, JoystickSensorThread, NavGraphROSPubThread, RosNavgraphBreakoutThread, StaticTransformsThread, WebviewPtzCamThread, fawkes::NetworkAcceptorThread, IMUSensorThread, JacoBimanualGotoThread, JoystickTeleOpThread, MongoRRDThread, ClipsTFThread, TfExampleThread, NavGraphStaticConstraintsThread, RobotinoRosJointsThread, ROSCmdVelThread, JacoInfoThread, JacoOpenraveThread, OpenRaveMessageHandlerThread, ProcRRDThread, ROSOdometryThread, TimeTrackerMainLoopThread, ClipsWebviewThread, JacoActThread, JacoBimanualActThread, KatanaSensorThread, ROSTalkerPubThread, BallPosLogThread, ExampleNetworkThread, GossipExampleSenderThread, GossipThread, JacoBimanualOpenraveThread, NaoQiBrokerThread, RosClockThread, RRDWebThread, OpenPRSAgentThread, PanTiltSensorThread, SkillerNavGraphFeature, GossipExampleReceiverThread, OpenPRSExampleThread, DynamixelSensorThread, RRDExampleThread, ExampleFinalizeNettlerThread, ExampleThread, fawkes::FamThread, BBLogReplayBlockedTimingThread, DynamixelActThread, PlayerTimeSyncThread, KatanaGripperThread, KatanaSensorAcquisitionThread, PlayerF2PThread, RoombaSensorThread, KatanaMotorControlThread, PlayerPostSyncThread, and KatanaCalibrationThread.
Definition at line 939 of file thread.cpp.
References finalize_prepared, fawkes::Mutex::lock(), loop(), loop_mutex, loopinterrupt_antistarve_mutex, OPMODE_WAITFORWAKEUP, fawkes::Mutex::stopby(), test_cancel(), fawkes::Mutex::unlock(), fawkes::WaitCondition::wait(), fawkes::Barrier::wait(), fawkes::WaitCondition::wake_all(), and yield().
Referenced by name(), KatanaSensorAcquisitionThread::run(), fawkes::FamThread::run(), GossipExampleSenderThread::run(), RosClockThread::run(), BallPosLogThread::run(), KatanaSensorThread::run(), JacoBimanualActThread::run(), JacoActThread::run(), TimeTrackerMainLoopThread::run(), OpenRaveMessageHandlerThread::run(), ProcRRDThread::run(), JacoInfoThread::run(), ROSOdometryThread::run(), TfExampleThread::run(), RobotinoRosJointsThread::run(), ROSCmdVelThread::run(), NavGraphStaticConstraintsThread::run(), JacoBimanualGotoThread::run(), JoystickTeleOpThread::run(), MongoRRDThread::run(), fawkes::NetworkAcceptorThread::run(), IMUSensorThread::run(), JoystickSensorThread::run(), RosNavgraphBreakoutThread::run(), StaticTransformsThread::run(), WebviewPtzCamThread::run(), LaserSensorThread::run(), RobotinoIrPclThread::run(), RoombaJoystickThread::run(), fawkes::FawkesNetworkServerClientThread::run(), RosNavigatorThread::run(), MongoLogTransformsThread::run(), FestivalSynthThread::run(), FvRetrieverThread::run(), fawkes::BlackBoardNetworkHandler::run(), LaserAcquisitionThread::run(), RobotinoSensorThread::run(), PanTiltDirectedPerceptionThread::run(), FliteSynthThread::run(), Roomba500Thread::run(), NaoQiLedThread::run(), OpenPRSThread::run(), PanTiltSonyEviD100PThread::run(), BlackBoardSynchronizationThread::run(), ClipsAgentThread::run(), PointCloudDBRetrieveThread::run(), PointCloudDBStoreThread::run(), ClipsNavGraphThread::run(), JacoGotoThread::run(), XmlRpcThread::run(), RobotinoActThread::run(), PointCloudDBMergeThread::run(), BBLogReplayThread::run(), OpenNiHandTrackerThread::run(), fawkes::ConfigNetworkHandler::run(), JoystickActThread::run(), LuaAgentPeriodicExecutionThread::run(), JoystickAcquisitionThread::run(), RefBoxCommThread::run(), PanTiltRX28Thread::run(), OpenNiUserTrackerThread::run(), fawkes::NetworkNameResolverThread::run(), NavGraphClustersThread::run(), MongoLogPointCloudThread::run(), DynamixelDriverThread::run(), AmclROSThread::run(), BBLoggerThread::run(), LaserPointCloudThread::run(), NavGraphThread::run(), LuaAgentContinuousExecutionThread::run(), DirectRobotinoComThread::run(), PointCloudDBROSCommThread::run(), fawkes::AvahiThread::run(), OpenNiPointCloudThread::run(), FvBaseThread::run(), fawkes::FawkesNetworkServerThread::run(), JacoOpenraveBaseThread::run(), fawkes::PluginNetworkHandler::run(), SkillerExecutionThread::run(), KatanaActThread::run(), AmclThread::run(), LaserFilterThread::run(), Bumblebee2Thread::run(), FvAcquisitionThread::run(), LaserClusterThread::run(), IMUAcquisitionThread::run(), fawkes::FawkesMainThread::run(), WebviewThread::run(), MongoLogLoggerThread::run(), fawkes::FawkesNetworkServerClientSendThread::run(), fawkes::FawkesNetworkClientSendThread::run(), TabletopObjectsThread::run(), fawkes::FawkesNetworkClientRecvThread::run(), and start().
bool Thread::running | ( | ) | const |
Check if the thread is running.
A thread is running if it currently is busy in its loop() or once() method.
Definition at line 855 of file thread.cpp.
References loop_mutex, fawkes::Mutex::try_lock(), and fawkes::Mutex::unlock().
|
static |
Set the cancel state of the current thread.
The cancel state can only be set on the current thread. Please also consider the documentation for pthread_setcancelstate().
new_state | new cancel state |
old_state | old cancel state |
Definition at line 1350 of file thread.cpp.
References CANCEL_DISABLED, and CANCEL_ENABLED.
Referenced by fawkes::MultiLogger::add_logger(), fawkes::MultiLogger::log(), fawkes::MultiLogger::log_debug(), fawkes::MultiLogger::log_error(), fawkes::MultiLogger::log_info(), fawkes::MultiLogger::log_warn(), TimeTrackerMainLoopThread::loop(), fawkes::FawkesMainThread::loop(), FvAcquisitionThread::loop(), name(), fawkes::WebServer::process(), fawkes::MultiLogger::remove_logger(), fawkes::MultiLogger::set_loglevel(), fawkes::MultiLogger::tlog(), fawkes::MultiLogger::tlog_debug(), fawkes::MultiLogger::tlog_error(), fawkes::MultiLogger::tlog_info(), fawkes::MultiLogger::tlog_warn(), fawkes::AvahiThread::unpublish_service(), fawkes::AvahiThread::unwatch_service(), fawkes::MultiLogger::vlog(), fawkes::MultiLogger::vlog_debug(), fawkes::MultiLogger::vlog_error(), fawkes::MultiLogger::vlog_info(), fawkes::MultiLogger::vlog_warn(), fawkes::MultiLogger::vtlog(), fawkes::MultiLogger::vtlog_debug(), fawkes::MultiLogger::vtlog_error(), fawkes::MultiLogger::vtlog_info(), and fawkes::MultiLogger::vtlog_warn().
|
protected |
Set wakeup coalescing.
The standard behavior of multiple calls to wakeup() (before the thread actually got woken up, for instance because a loop iteration was still running) is to execute one iteration for each wakeup. When setting coalescing, multiple calls will only cause a single execution of the loop.
coalesce | true to coalesce wakeups, false to keep the original behavior |
Definition at line 741 of file thread.cpp.
References OPMODE_CONTINUOUS.
Referenced by PanTiltDirectedPerceptionThread::bb_interface_message_received(), PanTiltSonyEviD100PThread::bb_interface_message_received(), PanTiltRX28Thread::bb_interface_message_received(), BBLoggerThread::BBLoggerThread(), name(), NavGraphGeneratorVisualizationThread::NavGraphGeneratorVisualizationThread(), NavGraphVisualizationThread::NavGraphVisualizationThread(), TabletopVisualizationThread::TabletopVisualizationThread(), and fawkes::WebviewJpegStreamProducer::WebviewJpegStreamProducer().
void Thread::set_delete_on_exit | ( | bool | del | ) |
Set whether the thread should be deleted on exit.
If you set this to true the thread instance is deleted if the threads exits (only on internal exits, not if you cancel the thread!). This is particularly useful if you only implement once() and not loop().
del | true to delete thread on exit, false otherwise |
Definition at line 1099 of file thread.cpp.
Referenced by name().
void Thread::set_flag | ( | uint32_t | flag | ) |
Set flag for the thread.
The first two bytes of the flags are reserved for custom usage from the outside and they are never used internally. The last two bytes are used to indicate internal states, like flagging a thread as bad (timing was not ok). Setting the latter bits may have influence on the inner workings on the thread and thus should only be done if you really know what you are doing.
flag | flag to set |
Definition at line 1126 of file thread.cpp.
Referenced by name().
void Thread::set_flags | ( | uint32_t | flags | ) |
Set all flags in one go.
flags | flags |
Definition at line 1148 of file thread.cpp.
Referenced by name().
|
protected |
Set name of thread.
If you want a more descriptive thread name you can do so by calling this method in your thread's constructor, and only in the constructor. Use parameters similar to printf().
format | format string |
Definition at line 761 of file thread.cpp.
Referenced by PanTiltDirectedPerceptionThread::bb_interface_message_received(), PanTiltSonyEviD100PThread::bb_interface_message_received(), PanTiltRX28Thread::bb_interface_message_received(), BBLoggerThread::BBLoggerThread(), BBLogReplayBlockedTimingThread::BBLogReplayBlockedTimingThread(), BBLogReplayThread::BBLogReplayThread(), BlackBoardSynchronizationThread::BlackBoardSynchronizationThread(), CruizCoreXG1010AcquisitionThread::CruizCoreXG1010AcquisitionThread(), DynamixelDriverThread::DynamixelDriverThread(), FvAcquisitionThread::FvAcquisitionThread(), FvRetrieverThread::FvRetrieverThread(), HokuyoUrgAcquisitionThread::HokuyoUrgAcquisitionThread(), HokuyoUrgGbxAcquisitionThread::HokuyoUrgGbxAcquisitionThread(), IMUSensorThread::IMUSensorThread(), LaseEdlAcquisitionThread::LaseEdlAcquisitionThread(), LaserClusterThread::LaserClusterThread(), LaserFilterThread::LaserFilterThread(), LaserSensorThread::LaserSensorThread(), name(), PanTiltDirectedPerceptionThread::PanTiltDirectedPerceptionThread(), PanTiltRX28Thread::PanTiltRX28Thread(), PanTiltSonyEviD100PThread::PanTiltSonyEviD100PThread(), SickTiM55xCommonAcquisitionThread::SickTiM55xCommonAcquisitionThread(), SickTiM55xEthernetAcquisitionThread::SickTiM55xEthernetAcquisitionThread(), SickTiM55xUSBAcquisitionThread::SickTiM55xUSBAcquisitionThread(), and fawkes::WebviewJpegStreamProducer::WebviewJpegStreamProducer().
|
protected |
Set operation mode.
This can be done at any time and the thread will from the next cycle on run in the new mode.
op_mode | new operation mode |
Definition at line 690 of file thread.cpp.
References OPMODE_CONTINUOUS, and OPMODE_WAITFORWAKEUP.
Referenced by XmlRpcThread::init(), name(), and FvAcquisitionThread::set_aqtmode().
|
protected |
Set concurrent execution of prepare_finalize() and loop().
Usually calls to prepare_finalize() and a running loop() are mutually exclusive. The prepare_finalize() call will wait for the current loop() run to finish before calling the user implementation. If you have a thread that blocks in its loop for example in a blocking system call this would lead to a dead-lock if no condition that makes the loop finish occurs. For this reason this method has been added. If you set this to true then prepare_finalize() can be executed concurrent to a running loop() call. If this is critical for parts of loop() you have to protect the critical sections by yourself. Use this sparsely and be sure you really know what you are doing. This method is necessary in some situations and powerful if used wisely. By default a thread will enforce mutual exclusion.
concurrent | true to allow concurrent execution of prepare_finalize() and loop(), false to enforce mutual exclusion (the latter being the default) |
Definition at line 727 of file thread.cpp.
Referenced by fawkes::AvahiThread::AvahiThread(), BBLogReplayBlockedTimingThread::BBLogReplayBlockedTimingThread(), BBLogReplayThread::BBLogReplayThread(), BlackBoardSynchronizationThread::BlackBoardSynchronizationThread(), DirectRobotinoComThread::DirectRobotinoComThread(), EclipseAgentThread::EclipseAgentThread(), LuaAgentContinuousExecutionThread::fam_event(), fawkes::FawkesNetworkServerClientThread::FawkesNetworkServerClientThread(), FvAcquisitionThread::FvAcquisitionThread(), JoystickAcquisitionThread::JoystickAcquisitionThread(), MongoLogImagesThread::MongoLogImagesThread(), MongoLogPointCloudThread::MongoLogPointCloudThread(), MongoLogTransformsThread::MongoLogTransformsThread(), MongoRRDThread::MongoRRDThread(), name(), fawkes::NetworkAcceptorThread::NetworkAcceptorThread(), ProcRRDThread::ProcRRDThread(), RosClockThread::RosClockThread(), RRDThread::RRDThread(), fawkes::WebviewJpegStreamProducer::WebviewJpegStreamProducer(), WebviewPtzCamThread::WebviewPtzCamThread(), WebviewThread::WebviewThread(), and XmlRpcThread::XmlRpcThread().
void Thread::set_prepfin_hold | ( | bool | hold | ) |
Hold prepare_finalize().
In some situations you have to hold the finalization of a thread up to a certain safe point. With set_prepfin_hold() you can do this. If you set hold
to true then a call to prepare_finalize()
will block until set_prepfin_hold(false)
is called.
hold | true to hold next call to prepare_finalize() , false to release it |
Exception | thrown if prepare_finalize() has already been called before trying to set hold to true. |
Definition at line 794 of file thread.cpp.
References finalize_prepared, fawkes::Mutex::lock(), fawkes::Mutex::unlock(), and fawkes::WaitCondition::wake_all().
Referenced by name().
void Thread::start | ( | bool | wait = true | ) |
Call this method to start the thread.
This method has to be called after the thread has been instantiated and initialized to start it. To meet the Fawkes guarantees you this may only be called if the initialization of the thread has been successful.
wait | if true this method will block until the thread is really started, otherwise it will only initiate the startup and return immediately |
Definition at line 511 of file thread.cpp.
References fawkes::Mutex::lock(), loop_mutex, once(), run(), fawkes::Mutex::unlock(), and fawkes::Barrier::wait().
Referenced by firevision::FuseServer::add_connection(), fawkes::FawkesNetworkServerThread::add_connection(), JoystickBlackBoardActListener::bb_interface_message_received(), fawkes::ConfigNetworkHandler::ConfigNetworkHandler(), SkillShellThread::connection_established(), fawkes::FawkesMainThread::full_start(), FuseViewerGtkWindow::FuseViewerGtkWindow(), FawkesBeepDaemon::handle_signal(), Roomba500Thread::init(), NaoQiDCMThread::init(), KatanaActThread::init(), MongoLogPointCloudThread::loop(), NavGraphThread::loop(), NetLogGuiGtkWindow::NetLogGuiGtkWindow(), fawkes::NetworkNameResolver::NetworkNameResolver(), fawkes::FawkesNetworkServerClientThread::once(), fawkes::PluginManager::PluginManager(), FestivalSynthThread::say(), fawkes::ThreadManager::set_inifin(), FuseTransferWidget::set_remote_lut_list_trv(), fawkes::LuaContext::setup_fam(), fawkes::LocalBlackBoard::start_nethandler(), and KatanaActThread::update_sensor_values().
bool Thread::started | ( | ) | const |
Check if thread has been started.
Definition at line 824 of file thread.cpp.
Referenced by JacoActThread::loop().
|
protected |
Set cancellation point.
Tests if the thread has been canceled and if so exits the thread.
Definition at line 889 of file thread.cpp.
Referenced by TimeTrackerMainLoopThread::loop(), fawkes::FawkesMainThread::loop(), name(), and run().
pthread_t Thread::thread_id | ( | ) | const |
void Thread::unset_flag | ( | uint32_t | flag | ) |
Unset flag.
Unsets a specified flag.
flag | flag to unset |
Definition at line 1138 of file thread.cpp.
Referenced by name().
void Thread::wait_loop_done | ( | ) |
Wait for the current loop iteration to finish.
Definition at line 1053 of file thread.cpp.
References fawkes::Mutex::lock(), fawkes::Mutex::unlock(), and fawkes::WaitCondition::wait().
Referenced by OpenNiPointCloudThread::finalize().
bool Thread::waiting | ( | ) | const |
Check if thread is currently waiting for wakeup.
A continuous thread is never waiting for wakeup and thus will always return false. A wait-for-wakeup thread is waiting when it has passed the wakeup barrier (if supplied) and is now waiting for the next call to wakeup() to run again.
Definition at line 875 of file thread.cpp.
References OPMODE_WAITFORWAKEUP.
void Thread::wakeup | ( | ) |
Wake up thread.
If the thread is being used in wait for wakeup mode this will wake up the waiting thread.
Definition at line 1000 of file thread.cpp.
References OPMODE_WAITFORWAKEUP, and fawkes::WaitCondition::wake_all().
Referenced by fawkes::FawkesNetworkServerThread::add_connection(), fawkes::WebviewJpegStreamProducer::add_subscriber(), fawkes::BlackBoardOnUpdateWaker::bb_interface_data_changed(), BBLoggerThread::bb_interface_data_changed(), fawkes::BlackBoardOnMessageWaker::bb_interface_message_received(), FestivalSynthThread::bb_interface_message_received(), PanTiltDirectedPerceptionThread::bb_interface_message_received(), PanTiltSonyEviD100PThread::bb_interface_message_received(), FliteSynthThread::bb_interface_message_received(), DynamixelDriverThread::bb_interface_message_received(), PanTiltRX28Thread::bb_interface_message_received(), fawkes::FawkesNetworkServerClientThread::connection_died(), firevision::FuseServer::connection_died(), fawkes::FawkesNetworkServerClientSendThread::enqueue(), NavGraphVisualizationThread::graph_changed(), fawkes::BlackBoardNetworkHandler::handle_network_message(), fawkes::ConfigNetworkHandler::handle_network_message(), fawkes::PluginNetworkHandler::handle_network_message(), NaoQiDCMThread::init(), fawkes::FawkesNetworkServerClientThread::loop(), NavGraphGeneratorThread::loop(), DynamixelDriverThread::loop(), fawkes::FawkesMainThread::loop(), fawkes::WebviewJpegStreamProducer::loop(), NavGraphGeneratorVisualizationThread::publish(), NavGraphVisualizationThread::reset_plan(), fawkes::NetworkNameResolverThread::resolve_address(), fawkes::NetworkNameResolverThread::resolve_name(), fawkes::FawkesNetworkServerClientThread::set_clid(), NavGraphVisualizationThread::set_current_edge(), NavGraphVisualizationThread::set_graph(), NavGraphVisualizationThread::set_traversal(), KatanaActThread::update_sensor_values(), TabletopVisualizationThread::visualize(), and fawkes::WebviewJpegStreamProducer::wait_for_next_frame().
void Thread::wakeup | ( | Barrier * | barrier | ) |
Wake up thread and wait for barrier afterwards.
If the thread is being used in wait for wakeup mode this will wake up the waiting thread. Additionally after the loop is finished
barrier | barrier to wait for after loop |
Definition at line 1027 of file thread.cpp.
References OPMODE_WAITFORWAKEUP, and fawkes::WaitCondition::wake_all().
|
protected |
Check if wakeups are pending.
Definition at line 1110 of file thread.cpp.
Referenced by name().
|
protected |
Yield the processor to another thread or process.
This will suspend the execution of the current thread in favor of other threads. The thread will then be re-scheduled for later execution. Use this method to make sure that other threads get a chance to get the CPU for example if your thread is waiting for results from other threads.
Definition at line 902 of file thread.cpp.
Referenced by SickTiM55xEthernetAcquisitionThread::loop(), SickTiM55xUSBAcquisitionThread::loop(), CruizCoreXG1010AcquisitionThread::loop(), fawkes::FawkesMainThread::loop(), name(), run(), and ~Thread().
|
protected |
True if prepare_finalize() has been called and was not stopped with a cancel_finalize(), false otherwise.
This can also be used in finalize() to detect whether prepare_finalize() was run or not.
Definition at line 138 of file thread.h.
Referenced by cancel_finalize(), DirectRobotinoComThread::loop(), prepare_finalize(), run(), DirectRobotinoComThread::set_bumper_estop_enabled(), DirectRobotinoComThread::set_desired_vel(), set_prepfin_hold(), and Thread().
|
static |
Standard thread flag: "thread is bad".
Definition at line 65 of file thread.h.
Referenced by flagged_bad(), fawkes::ThreadList::try_recover(), and fawkes::ThreadList::wakeup_and_wait().
|
mutableprotected |
Mutex that is used to protect a call to loop().
This mutex is locked just before loop() is called and unlocked right after it has finished. So you can use this lock in your derivate to make sure that a method does not run while the loop runs. For example assume that we have a method set_parameter(int x). This method may only be called if loop() is not running or unpredictable results will occur. To do this you could write the method as
See documentation for loopinterrupt_antistarve_mutex why you need to use two mutexes here.
Definition at line 139 of file thread.h.
Referenced by cancel_finalize(), StaticTransformsThread::finalize(), join(), LaserSimThread::loop(), NavGraphGeneratorThread::loop(), LocalizationSimThread::loop(), RobotinoSimThread::loop(), loop(), RosMoveBaseThread::once(), RosSkillerThread::once(), prepare_finalize(), run(), running(), KatanaSensorAcquisitionThread::set_enabled(), start(), Thread(), KatanaActThread::update_sensor_values(), fawkes::FawkesNetworkServerClientSendThread::wait_for_all_sent(), and ~Thread().
|
protected |
Mutex to avoid starvation when trying to lock loop_mutex.
If you want to interrupt the main loop only locking loop_mutex is not enough, as this might make your try to lock it starve if the loop is running too fast (for example on a continuous thread). Because of this you always need to lock both mutexes. The anti-starve mutex will only be visited shortly and thus allows you to lock it easily. This will then block the thread from trying to lock the loop_mutex. See loop_mutex for an example.
Definition at line 140 of file thread.h.
Referenced by prepare_finalize(), run(), fawkes::FawkesMainThread::set_mainloop_thread(), Thread(), and ~Thread().