Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpThread Class Reference

#include <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=nullptr)
void create (vpThread::Fn fn, vpThread::Args args=nullptr)
virtual ~vpThread ()
void join ()
Handle getHandle ()
bool joinable ()

Protected Attributes

Handle m_handle
bool m_isCreated
bool m_isJoinable

Detailed Description

Deprecated
Use rather std::thread.

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.

Definition at line 80 of file vpThread.h.

Member Typedef Documentation

◆ Args

typedef void* vpThread::Args

Definition at line 84 of file vpThread.h.

◆ Fn

typedef void *(* vpThread::Fn) (Args)

Definition at line 86 of file vpThread.h.

◆ Handle

typedef pthread_t vpThread::Handle

Definition at line 87 of file vpThread.h.

◆ Return

typedef void* vpThread::Return

Definition at line 85 of file vpThread.h.

Constructor & Destructor Documentation

◆ vpThread() [1/2]

vpThread::vpThread ( )
inline

Default constructor that does nothing. To attach a function to this thread of execution you need to call create().

Definition at line 99 of file vpThread.h.

References m_handle, m_isCreated, and m_isJoinable.

◆ vpThread() [2/2]

vpThread::vpThread ( vpThread::Fn fn,
vpThread::Args args = nullptr )
inline

Construct a thread object that represents a new joinable thread of execution. The new thread of execution calls fn passing args as arguments.

Parameters
fn: A pointer to a function.
args: Arguments passed to the call to fn (if any).

Definition at line 108 of file vpThread.h.

References create(), m_handle, m_isCreated, and m_isJoinable.

◆ ~vpThread()

virtual vpThread::~vpThread ( )
inlinevirtual

Destroy the thread.

Definition at line 144 of file vpThread.h.

References join(), and m_handle.

Member Function Documentation

◆ create()

void vpThread::create ( vpThread::Fn fn,
vpThread::Args args = nullptr )
inline

Creates a thread object that represents a new joinable thread of execution.

Parameters
fn: A pointer to a function.
args: Arguments passed to the call to fn (if any).

Definition at line 119 of file vpThread.h.

References vpException::cannotUseConstructorError, vpException::fatalError, m_handle, m_isCreated, and m_isJoinable.

Referenced by vpThread().

◆ getHandle()

Handle vpThread::getHandle ( )
inline

Returns a value used to access implementation-specific information associated to the thread.

Definition at line 183 of file vpThread.h.

References m_handle.

◆ join()

void vpThread::join ( )
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.

See also
joinable()

Definition at line 163 of file vpThread.h.

References m_handle, and m_isJoinable.

Referenced by ~vpThread().

◆ joinable()

bool vpThread::joinable ( )
inline

Returns whether the thread object is joinable.

A thread object is not joinable in any of these cases:

  • if it was default-constructed and create() was not called.
  • if join() has been called.
See also
join()

Definition at line 194 of file vpThread.h.

References m_isJoinable.

Member Data Documentation

◆ m_handle

Handle vpThread::m_handle
protected

Thread handle.

Definition at line 197 of file vpThread.h.

Referenced by create(), getHandle(), join(), vpThread(), vpThread(), and ~vpThread().

◆ m_isCreated

bool vpThread::m_isCreated
protected

Indicates if the thread is created.

Definition at line 198 of file vpThread.h.

Referenced by create(), vpThread(), and vpThread().

◆ m_isJoinable

bool vpThread::m_isJoinable
protected

Indicates if the thread is joinable.

Definition at line 199 of file vpThread.h.

Referenced by create(), join(), joinable(), vpThread(), and vpThread().