Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
icl_core::thread::Thread Class Referenceabstract

#include <Thread.h>

Inheritance diagram for icl_core::thread::Thread:
Inheritance graph
[legend]

Public Member Functions

void cancel ()
 
bool checkHardRealtime ()
 
bool execute () const
 
bool executesHardRealtime () const
 
icl_core::String getDescription () const
 
bool isHardRealtime () const
 
void join ()
 
virtual void onStop ()
 
icl_core::ThreadPriority priority () const
 
virtual void run ()=0
 
bool running () const
 
void setDescription (const icl_core::String &description)
 
bool setHardRealtime (bool hard_realtime=true)
 
bool setPriority (icl_core::ThreadPriority priority)
 
bool start ()
 
void stop ()
 
 Thread (const icl_core::String &description, icl_core::ThreadPriority priority=0)
 
icl_core::ThreadId threadId () const
 
const char * threadInfo () const
 
bool threadSelf () const
 
bool wait ()
 
bool wait (const icl_core::TimeStamp &timeout)
 
bool wait (const icl_core::TimeSpan &timeout)
 
virtual ~Thread ()
 

Static Public Member Functions

static icl_core::ThreadId selfId ()
 

Private Member Functions

virtual void makePeriodic ()
 
void runThread ()
 
void waitStarted () const
 

Private Attributes

bool m_execute
 
bool m_finished
 
ThreadImplm_impl
 
bool m_joined
 
icl_core::ThreadPriority m_priority
 
bool m_starting
 
icl_core::String m_thread_info
 
Mutex m_thread_mutex
 

Friends

class ThreadImplLxrt33
 
class ThreadImplLxrt35
 
class ThreadImplLxrt38
 
class ThreadImplPosix
 
class ThreadImplWin32
 

Additional Inherited Members

- Protected Member Functions inherited from icl_core::Noncopyable
 Noncopyable ()
 
virtual ~Noncopyable ()
 

Detailed Description

Only for base functionality. You may use functions of this class, but never create one. Use template class TThreadContainer instead.

For developers: The ThreadImpl class must implement the following functions:

Definition at line 77 of file icl_core_thread/Thread.h.

Constructor & Destructor Documentation

icl_core::thread::Thread::Thread ( const icl_core::String description,
icl_core::ThreadPriority  priority = 0 
)

Constructor. If the priority is negative and LXRT is available, the thread is processed in hard realtime.

Definition at line 49 of file icl_core_thread/Thread.cpp.

icl_core::thread::Thread::~Thread ( )
virtual

Deletes the thread. Stops it if it is still running.

Definition at line 83 of file icl_core_thread/Thread.cpp.

Member Function Documentation

void icl_core::thread::Thread::cancel ( )

Forces the thread to terminate. If this function is called the thread has no chance to cleanup resources or its current computation.

Use stop() in combination with wait() or join() to cooperatively terminate a thread.

Definition at line 95 of file icl_core_thread/Thread.cpp.

bool icl_core::thread::Thread::checkHardRealtime ( )

Checks whether the RT task is in hard or soft real time mode. Returns false, if the thread is in hard real time mode or is no hard real time thread at all.

If this function is called from inside the thread, it will be reset into hard real time mode if necessary.

Definition at line 109 of file icl_core_thread/Thread.cpp.

bool icl_core::thread::Thread::execute ( ) const
inline

Call this from inside the thread code if you want to check whether the thread was demanded to stop from outside.

Returns
false if the thread has been asked to stop, true otherwise.

Definition at line 117 of file icl_core_thread/Thread.h.

bool icl_core::thread::Thread::executesHardRealtime ( ) const

Returns true if this thread actually executes in hard realtime mode.

Definition at line 133 of file icl_core_thread/Thread.cpp.

icl_core::String icl_core::thread::Thread::getDescription ( ) const

Returns the thread's description.

Definition at line 123 of file icl_core_thread/Thread.cpp.

bool icl_core::thread::Thread::isHardRealtime ( ) const

Returns true if this is defined to be a hard realtime thread.

Definition at line 128 of file icl_core_thread/Thread.cpp.

void icl_core::thread::Thread::join ( )

Wait for the thread to finish. Returns immediately if the thread is not running.

Definition at line 138 of file icl_core_thread/Thread.cpp.

void icl_core::thread::Thread::makePeriodic ( )
privatevirtual

Makes the thread periodic.

This function is overridden in PeriodicThread.

Reimplemented in icl_core::thread::PeriodicThread.

Definition at line 504 of file icl_core_thread/Thread.cpp.

virtual void icl_core::thread::Thread::onStop ( )
inlinevirtual

This function is called from the Stop() function. Subclasses can implement this function, if they need to do special processing when the thread is stopped.

Definition at line 141 of file icl_core_thread/Thread.h.

icl_core::ThreadPriority icl_core::thread::Thread::priority ( ) const

Returns the thread's priority.

Definition at line 148 of file icl_core_thread/Thread.cpp.

virtual void icl_core::thread::Thread::run ( )
pure virtual

This is the function running in the thread. This has to be reimplemented from derived classes. If you start the thread by calling Start() this function is executed in the thread. If you call don't want that function to be executed in the thread you could call it directly in your derived class.

Implemented in BurnThread, PeriodicTestThread, icl_core::dispatch::PeriodicDispatchThread, icl_core::thread::ActiveObject, LoggingThread, MutexTestThread, RWLockTestThread, and TestThread.

bool icl_core::thread::Thread::running ( ) const
inline
Returns
true if the thread is currently running.

Definition at line 153 of file icl_core_thread/Thread.h.

void icl_core::thread::Thread::runThread ( )
private

Executes the thread. This function is intended to be called from thread implementations.

Definition at line 217 of file icl_core_thread/Thread.cpp.

static icl_core::ThreadId icl_core::thread::Thread::selfId ( )
inlinestatic

Returns the ID of the thread in which this function is called.

Definition at line 234 of file icl_core_thread/Thread.h.

void icl_core::thread::Thread::setDescription ( const icl_core::String description)

Set the description of the thread.

Depending on the platform this description is either only kept within the icl_core implementation or - if supported - also handed over to the system.

Definition at line 153 of file icl_core_thread/Thread.cpp.

bool icl_core::thread::Thread::setHardRealtime ( bool  hard_realtime = true)

Set this thread to hard or soft realtime mode.

Returns
true if the thread could be set to the desired realtime mode, false otherwise.

Definition at line 158 of file icl_core_thread/Thread.cpp.

bool icl_core::thread::Thread::setPriority ( icl_core::ThreadPriority  priority)

Changes the priority to the new specified value. Returns false if not successful. In the constructor of Thread the Priority is set to a sensible default value that depends on the underlying operation system.

Definition at line 163 of file icl_core_thread/Thread.cpp.

bool icl_core::thread::Thread::start ( )

Starts the thread.

Returns
true if the thread has been started successfully, false if an error occured while starting the thread.

Definition at line 176 of file icl_core_thread/Thread.cpp.

void icl_core::thread::Thread::stop ( )
inline

Cooperatively stops the thread.

The thread's main loop must continuously check if the thread has been stopped by calling IsStopped().

Definition at line 189 of file icl_core_thread/Thread.h.

icl_core::ThreadId icl_core::thread::Thread::threadId ( ) const

Returns the ID of this thread.

Definition at line 212 of file icl_core_thread/Thread.cpp.

const char* icl_core::thread::Thread::threadInfo ( ) const
inline

Get the thread info, which consists of the thread description and the thread ID. This is mainly used for internal logging messages.

Definition at line 199 of file icl_core_thread/Thread.h.

bool icl_core::thread::Thread::threadSelf ( ) const
inline

Check whether the calling thread is the thread running by this object.

Definition at line 204 of file icl_core_thread/Thread.h.

bool icl_core::thread::Thread::wait ( )

Waits indefinitely until the thread has finished execution.

Returns
Always returns true.

Definition at line 250 of file icl_core_thread/Thread.cpp.

bool icl_core::thread::Thread::wait ( const icl_core::TimeStamp timeout)

Waits until either the thread has finished execution or the specified absolute timeout elapses.

Returns
true if the thread has finished or false if the timeout has elapsed.

Definition at line 255 of file icl_core_thread/Thread.cpp.

bool icl_core::thread::Thread::wait ( const icl_core::TimeSpan timeout)

Waits until either the thread has finished execution or the specified relative timeout elapses.

Returns
true if the thread has finished or false if the timeout has elapsed.

Definition at line 305 of file icl_core_thread/Thread.cpp.

void icl_core::thread::Thread::waitStarted ( ) const
private

Suspends the calling thread until thread is started.

Definition at line 495 of file icl_core_thread/Thread.cpp.

Friends And Related Function Documentation

friend class ThreadImplLxrt33
friend

Definition at line 412 of file icl_core_thread/Thread.h.

friend class ThreadImplLxrt35
friend

Definition at line 413 of file icl_core_thread/Thread.h.

friend class ThreadImplLxrt38
friend

Definition at line 414 of file icl_core_thread/Thread.h.

friend class ThreadImplPosix
friend

Definition at line 415 of file icl_core_thread/Thread.h.

friend class ThreadImplWin32
friend

Definition at line 416 of file icl_core_thread/Thread.h.

Member Data Documentation

bool icl_core::thread::Thread::m_execute
private

Definition at line 398 of file icl_core_thread/Thread.h.

bool icl_core::thread::Thread::m_finished
private

Definition at line 399 of file icl_core_thread/Thread.h.

ThreadImpl* icl_core::thread::Thread::m_impl
private

Definition at line 408 of file icl_core_thread/Thread.h.

bool icl_core::thread::Thread::m_joined
private

Definition at line 400 of file icl_core_thread/Thread.h.

icl_core::ThreadPriority icl_core::thread::Thread::m_priority
private

Definition at line 404 of file icl_core_thread/Thread.h.

bool icl_core::thread::Thread::m_starting
private

Definition at line 401 of file icl_core_thread/Thread.h.

icl_core::String icl_core::thread::Thread::m_thread_info
private

Definition at line 403 of file icl_core_thread/Thread.h.

Mutex icl_core::thread::Thread::m_thread_mutex
private

Definition at line 406 of file icl_core_thread/Thread.h.


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


fzi_icl_core
Author(s):
autogenerated on Mon Jun 10 2019 13:17:59