Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
Thread Class Referenceabstract

#include <elm/sys/Thread.h>

Public Member Functions

virtual ~Thread (void)
 
Runnablerunnable (void) const
 
virtual void start (void)=0
 
virtual void join (void)=0
 
virtual void kill (void)=0
 
virtual bool isRunning (void)=0
 

Static Public Member Functions

static Threadmake (Runnable &runnable)
 
static Threadcurrent (void)
 
static void setRootRunnable (Runnable &runnable)
 

Protected Member Functions

 Thread (Runnable &runnable)
 
virtual void stop (void)=0
 

Protected Attributes

Runnable_runnable
 

Detailed Description

Portable thread implementation A thread executes in a concurrent execution flow the given Runnable object.

The threads execution supports:

Constructor & Destructor Documentation

◆ ~Thread()

~Thread ( void  )
virtual

◆ Thread()

Thread ( Runnable runnable)
protected

References Thread::runnable().

Member Function Documentation

◆ current()

Thread * current ( void  )
static

Get the current thread.

Returns
Current thread.

Referenced by Runnable::current().

◆ isRunning()

bool isRunning ( void  )
pure virtual

Test if the current thread is running.

Returns
True if the thread is running, false else.

◆ join()

void join ( void  )
pure virtual

Wait for the current thread to stop.

◆ kill()

void kill ( void  )
pure virtual

Kill the current thread: notice that this method does not allow any synchronization, the thread will be killed but guarantee can be done at which program point it will happen.

Exceptions
ThreadExceptionThrown if the thread is already dead.

◆ make()

Thread * make ( Runnable runnable)
static

Build a new portable thread. Notice that the runnable is not executed when the thread is created. It starts only when a call to start() is performed!

Returns
Built thread or null if there is no more resources.

bool Mutex::tryLock(void); If the mutex is free, acquire it. Else return immediately without blocking.

Returns
True if the mutex has been acquired, false else.
Exceptions
SystemExceptionNo more place in waiting queue. Build a new thread for the given runnable.

References Thread::runnable().

Referenced by JobScheduler::start().

◆ runnable()

Runnable& runnable ( void  ) const
inline

◆ setRootRunnable()

void setRootRunnable ( Runnable runnable)
static

Convenient function to set the runnable of root thread.

Parameters
runnableRunnable to assign to the root thread.

◆ start()

void start ( void  )
pure virtual

Start the execution of the thread and perform the call to Runnable::run(). The thread is stopped when Runnable::run() returns, when it is killed or when the Runnable::run() performs a call to stop.

Exceptions
ThreadExceptionIf no more resources are available for the thread.

◆ stop()

void stop ( void  )
protectedpure virtual

Stop the current thread.

Referenced by Runnable::stop().

Member Data Documentation

◆ _runnable

Runnable* _runnable
protected

Referenced by Thread::runnable().


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