Ocean
Ocean::ThreadPool::PoolThread Class Reference

This class implements one thread of this thread pool. More...

Inheritance diagram for Ocean::ThreadPool::PoolThread:

Public Member Functions

 PoolThread (const std::string &name)
 Creates a new thread object. More...
 
 ~PoolThread () override
 Destructs a thread object. More...
 
bool isBusy () const
 Returns whether this thread is currently busy. More...
 
void invoke (Function &&function)
 Sets the thread function. More...
 

Protected Member Functions

void threadRun () override
 Thread run function. More...
 
- Protected Member Functions inherited from Ocean::Thread
 Thread (const Thread &thread)=delete
 Disabled copy constructor. More...
 
void createThread ()
 Creates the thread itself. More...
 
void destroyThread ()
 Destroys the thread itself. More...
 
void stopThreadExplicitly (const unsigned int timeout=5000u)
 Tries to stop the thread gracefully. More...
 
Threadoperator= (const Thread &thread)=delete
 The disabled assign operator. More...
 
 Thread (const std::string &name=std::string())
 Creates a new thread object. More...
 
 Thread (const unsigned int randomNumberSeedValue, const std::string &name=std::string())
 Creates a new thread object. More...
 
virtual ~Thread ()
 Destructs a thread object. More...
 
bool startThread ()
 Starts the thread. More...
 
void stopThread ()
 Informs the thread to stop. More...
 
bool terminateThread ()
 Terminates the thread. More...
 
bool joinThread (const unsigned int timeout=(unsigned int)(-1))
 Waits until this thread has been stopped. More...
 
bool shouldThreadStop () const
 Returns whether this thread should stop. More...
 
bool isThreadInvokedToStart () const
 Returns whether this thread has been invoked to start immediately. More...
 
bool isThreadActive () const
 Returns whether this thread is active. More...
 

Protected Attributes

Signal signal_
 Internal signal handling the internal thread execution. More...
 
Function function_
 The function that is invoked in this thread. More...
 
Lock lock_
 Thread lock. More...
 

Additional Inherited Members

- Protected Types inherited from Ocean::Thread
typedef std::pair< pthread_t, bool > TimedJoinPair
 Definition of a pair holding a thread id and a boolean state. More...
 
enum  ThreadPriority {
  PRIORITY_IDLE , PRIORTY_BELOW_NORMAL , PRIORTY_NORMAL , PRIORTY_ABOVE_NORMAL ,
  PRIORTY_HIGH , PRIORTY_REALTIME
}
 Definition of different thread priority values. More...
 
- Static Protected Member Functions inherited from Ocean::Thread
static void sleep (unsigned int ms)
 Sleeps the calling thread for a given time. More...
 
static void giveUp ()
 Gives up the remaining thread time. More...
 
static ThreadId currentThreadId ()
 Returns the thread id of the current (calling) thread. More...
 
static ThreadPriority threadPriority ()
 Returns the priority of the current thread. More...
 
static bool setThreadPriority (const ThreadPriority priority)
 Sets the priority of the current thread. More...
 
template<typename TObject , typename TExpectedValue >
static bool waitForValue (TObject &object, const TExpectedValue &expectedValue, const double timeout=-1.0)
 Waits until an object/variable has an expected value. More...
 
template<typename TObject , typename TExpectedValue >
static bool waitForValue (TObject &object, const TExpectedValue &expectedValue, TemporaryScopedLock &temporaryScopedLock, const double timeout=-1.0)
 Waits until an object/variable has an expected value. More...
 
static int pthread_timedjoin_np (pthread_t thread, void **retval, const struct timespec *abstime)
 Implements a thread join function with timeout value. More...
 

Detailed Description

This class implements one thread of this thread pool.

Constructor & Destructor Documentation

◆ PoolThread()

Ocean::ThreadPool::PoolThread::PoolThread ( const std::string &  name)
explicit

Creates a new thread object.

Parameters
nameThe thread name

◆ ~PoolThread()

Ocean::ThreadPool::PoolThread::~PoolThread ( )
override

Destructs a thread object.

Member Function Documentation

◆ invoke()

void Ocean::ThreadPool::PoolThread::invoke ( Function &&  function)

Sets the thread function.

Parameters
functionThe thread function that will be invoked in this thread

◆ isBusy()

bool Ocean::ThreadPool::PoolThread::isBusy ( ) const
inline

Returns whether this thread is currently busy.

Returns
True, if so

◆ threadRun()

void Ocean::ThreadPool::PoolThread::threadRun ( )
overrideprotectedvirtual

Thread run function.

Implements Ocean::Thread.

Field Documentation

◆ function_

Function Ocean::ThreadPool::PoolThread::function_
protected

The function that is invoked in this thread.

◆ lock_

Lock Ocean::ThreadPool::PoolThread::lock_
mutableprotected

Thread lock.

◆ signal_

Signal Ocean::ThreadPool::PoolThread::signal_
protected

Internal signal handling the internal thread execution.


The documentation for this class was generated from the following file: