Visual Servoing Platform
version 3.1.0
|
#include <visp3/core/vpThread.h>
Public Types | |
typedef void * | Args |
typedef void * | Return |
typedef void *(* | Fn) (Args) |
typedef pthread_t | Handle |
Public Member Functions | |
vpThread () | |
vpThread (vpThread::Fn fn, vpThread::Args args=NULL) | |
void | create (vpThread::Fn fn, vpThread::Args args=NULL) |
virtual | ~vpThread () |
void | join () |
Handle | getHandle () |
bool | joinable () |
Protected Attributes | |
Handle | m_handle |
bool | m_isCreated |
bool | m_isJoinable |
Class to represent individual threads of execution. This class implements native pthread functionalities if available, or native Windows threading capabilities if pthread is not available under Windows.
There are two examples implemented in testMutex.cpp and testThread.cpp to show how to use this class. The content of test-thread.cpp that hightlights the main functionalities of this class is given hereafter:
More examples are provided in Tutorial: How to use multi-threading capabilities.
Definition at line 36 of file vpThread.h.
typedef void* vpThread::Args |
Definition at line 40 of file vpThread.h.
typedef void*(* vpThread::Fn) (Args) |
Definition at line 42 of file vpThread.h.
typedef pthread_t vpThread::Handle |
Definition at line 43 of file vpThread.h.
typedef void* vpThread::Return |
Definition at line 41 of file vpThread.h.
|
inline |
Default constructor that does nothing. To attach a function to this thread of execution you need to call create().
Definition at line 55 of file vpThread.h.
|
inline |
Construct a thread object that represents a new joinable thread of execution. The new thread of execution calls fn passing args as arguments.
fn | : A pointer to a function. |
args | : Arguments passed to the call to fn (if any). |
Definition at line 63 of file vpThread.h.
References create().
|
inlinevirtual |
|
inline |
Creates a thread object that represents a new joinable thread of execution.
fn | : A pointer to a function. |
args | : Arguments passed to the call to fn (if any). |
Definition at line 73 of file vpThread.h.
References vpException::cannotUseConstructorError, vpException::fatalError, m_handle, m_isCreated, and m_isJoinable.
Referenced by vpThread().
|
inline |
Returns a value used to access implementation-specific information associated to the thread.
Definition at line 137 of file vpThread.h.
References m_handle.
|
inline |
This function return when the thread execution has completed. This blocks the execution of the thread that calls this function until the function called on construction returns (if it hasn't yet).
After a call to this function, the thread object becomes non-joinable and can be destroyed safely.
Definition at line 117 of file vpThread.h.
References m_handle, and m_isJoinable.
Referenced by ~vpThread().
|
inline |
Returns whether the thread object is joinable.
A thread object is not joinable in any of these cases:
Definition at line 148 of file vpThread.h.
References m_isJoinable.
|
protected |
Thread handle.
Definition at line 151 of file vpThread.h.
Referenced by create(), getHandle(), join(), and ~vpThread().
|
protected |
Indicates if the thread is created.
Definition at line 152 of file vpThread.h.
Referenced by create().
|
protected |
Indicates if the thread is joinable.
Definition at line 153 of file vpThread.h.
Referenced by create(), join(), and joinable().