#include <CeylanThread.h>
Classes | |
class | ThreadException |
Raised when POSIX returns thread errors, mainly in creation. More... | |
class | Waiter |
Public Types | |
enum | TextOutputFormat { rawText, html } |
Defines what text output formats for TextDisplayable instances are available. More... | |
Public Member Functions | |
Thread () | |
Constructs an anonymous thread. | |
Thread (const std::string &name) | |
Constructs a named Thread object. | |
virtual | ~Thread () throw () |
Basic destructor. | |
virtual void | run () |
Start point method. | |
virtual void | start ()=0 |
The start point for the newly created thread. | |
virtual void | askToStop () |
SystemSpecificThreadIdentifier & | id () const |
Returns this Thread's unique id. | |
bool | isClean () const |
Returns this thread's clean state. | |
bool | isRunning () const |
Tells whether the thread is running. | |
bool | hasTerminated () const |
Tells whether the thread has terminated its run. | |
bool | stopDemanded () const |
Tells whether the thread has been asked to stop. | |
void | waitUntilOver () |
virtual const std::string | toString (Ceylan::VerbosityLevels level=Ceylan::high) const |
Returns a user-friendly description of the state of this object. | |
const std::string & | getName () const |
Returns the name string. | |
Static Public Member Functions | |
static ThreadCount | GetNumberOfThreads () |
Returns the number of Thread objects currently existing. | |
static void | Sleep (System::Second seconds, System::Microsecond microseconds=0) |
Makes the calling thread sleep during specified time. | |
static void | Run (Thread &thread) |
Runs specified thread. | |
static const std::string | ToString (std::list< TextDisplayable * > displayables, Ceylan::VerbosityLevels level=Ceylan::high) |
Returns a user-friendly description of this list of pointers to text displayable instances. | |
static TextOutputFormat | GetOutputFormat () |
Returns the current overall text format to be used by TextDisplayable instances. | |
static void | SetOutputFormat (TextOutputFormat newOutputFormat) |
Sets the current overall text format to be used by TextDisplayable instances. | |
Protected Member Functions | |
void | cancel () |
virtual void | cleanup () |
This method is called after the run. | |
void | setRunning (bool newRunningStatus) |
Sets the running status. | |
virtual void | threadCreationFailed (int error) |
Called whenever the thread creation fails. | |
Static Protected Attributes | |
static TextOutputFormat | _OutputFormat = rawText |
The text format to be used currently by TextDisplayable instances. | |
Private Member Functions | |
Thread (const Thread &source) | |
Copy constructor made private to ensure that it will never be called. | |
Thread & | operator= (const Thread &source) |
Assignment operator made private to ensure that it will never be called. | |
Private Attributes | |
SystemSpecificThreadIdentifier * | _id |
This thread's unique system-specific identifier. | |
SystemSpecificThreadAttribute * | _attr |
This thread's system-specific attribute. | |
Ceylan::System::Synchronized < bool > | _terminated |
Tells whether this thread has terminated, i.e. | |
Ceylan::System::Synchronized < bool > | _clean |
Tells whether this thread is clean, i.e. | |
Ceylan::System::Synchronized < bool > | _running |
Tells whether this thread is currently running. | |
Ceylan::System::Synchronized < bool > | _mustStop |
Tells whether this thread must stop, i.e. | |
Static Private Attributes | |
static Synchronized < ThreadCount > * | _Number = 0 |
Number of the currently existing thread instances. |
Runnable, Synchronized, POSIX threads.
Definition at line 70 of file CeylanThread.h.
enum Ceylan::TextDisplayable::TextOutputFormat [inherited] |
Defines what text output formats for TextDisplayable instances are available.
Definition at line 124 of file CeylanTextDisplayable.h.
Thread::Thread | ( | ) |
Constructs an anonymous thread.
FeatureNotAvailableException | if the multithreading feature is not available. |
Definition at line 203 of file CeylanThread.cc.
Thread::Thread | ( | const std::string & | name | ) | [explicit] |
Constructs a named Thread object.
FeatureNotAvailableException | if the multithreading feature is not available. |
Definition at line 234 of file CeylanThread.cc.
Thread::~Thread | ( | ) | throw () [virtual] |
Basic destructor.
Definition at line 265 of file CeylanThread.cc.
References _attr, _id, _Number, cancel(), Ceylan::System::Runnable::getName(), and isRunning().
Ceylan::System::Thread::Thread | ( | const Thread & | source | ) | [private] |
Copy constructor made private to ensure that it will never be called.
The compiler should complain whenever this undefined constructor is called, implicitly or not.
void Thread::askToStop | ( | ) | [virtual] |
Definition at line 345 of file CeylanThread.cc.
References _mustStop, Ceylan::System::Runnable::getName(), and generalUtils::true.
void Thread::cancel | ( | ) | [protected] |
Definition at line 745 of file CeylanThread.cc.
References _id, _running, _terminated, generalUtils::false, Ceylan::System::Runnable::getName(), and generalUtils::true.
Referenced by ~Thread().
void Thread::cleanup | ( | ) | [protected, virtual] |
This method is called after the run.
It is executed by the launching thread.
Definition at line 765 of file CeylanThread.cc.
References _clean, and generalUtils::true.
Referenced by Run().
const string & Runnable::getName | ( | ) | const [inherited] |
Returns the name string.
Definition at line 75 of file CeylanRunnable.cc.
References Ceylan::System::Runnable::_name.
Referenced by askToStop(), cancel(), Run(), run(), waitUntilOver(), and ~Thread().
Ceylan::System::ThreadCount Thread::GetNumberOfThreads | ( | ) | [static] |
Returns the number of Thread objects currently existing.
Definition at line 485 of file CeylanThread.cc.
References _Number.
TextDisplayable::TextOutputFormat TextDisplayable::GetOutputFormat | ( | ) | [static, inherited] |
Returns the current overall text format to be used by TextDisplayable instances.
Definition at line 63 of file CeylanTextDisplayable.cc.
References Ceylan::TextDisplayable::_OutputFormat.
Referenced by Ceylan::formatStringList(), Ceylan::formatStringMap(), Ceylan::XML::XMLMarkup::toString(), Ceylan::Maths::Linear::Vector3::toString(), Ceylan::Maths::Linear::Vector2::toString(), Ceylan::Maths::Linear::Tripoint::toString(), Ceylan::Module::toString(), Ceylan::Maths::Linear::Matrix3::toString(), Ceylan::Maths::Linear::Matrix2::toString(), Ceylan::Maths::Linear::HomogeneousMatrix3::toString(), and Ceylan::Maths::Linear::Bipoint::toString().
bool Thread::hasTerminated | ( | ) | const |
Tells whether the thread has terminated its run.
Definition at line 386 of file CeylanThread.cc.
References _terminated.
Thread::SystemSpecificThreadIdentifier & Thread::id | ( | ) | const |
bool Thread::isClean | ( | ) | const |
Returns this thread's clean state.
Definition at line 368 of file CeylanThread.cc.
References _clean, and Ceylan::System::Synchronized< bool >::getValue().
bool Thread::isRunning | ( | ) | const |
Tells whether the thread is running.
Definition at line 377 of file CeylanThread.cc.
References _running, and Ceylan::System::Synchronized< bool >::getValue().
Referenced by ~Thread().
Assignment operator made private to ensure that it will never be called.
The compiler should complain whenever this undefined operator is called, implicitly or not.
void Thread::Run | ( | Thread & | thread | ) | [static] |
Runs specified thread.
Definition at line 521 of file CeylanThread.cc.
References cleanup(), Ceylan::System::Runnable::getName(), setRunning(), and start().
Referenced by run().
void Thread::run | ( | ) | [virtual] |
Start point method.
RunnableException | if the runnable could not be run. |
Implements Ceylan::System::Runnable.
Definition at line 305 of file CeylanThread.cc.
References _id, Ceylan::System::Runnable::getName(), Run(), and threadCreationFailed().
void TextDisplayable::SetOutputFormat | ( | TextOutputFormat | newOutputFormat | ) | [static, inherited] |
Sets the current overall text format to be used by TextDisplayable instances.
newOutputFormat | the new output format. |
Definition at line 72 of file CeylanTextDisplayable.cc.
References Ceylan::TextDisplayable::_OutputFormat.
Referenced by Ceylan::Log::LogHolder::LogHolder().
void Thread::setRunning | ( | bool | newRunningStatus | ) | [protected] |
Sets the running status.
Definition at line 778 of file CeylanThread.cc.
References _running, and Ceylan::toString().
Referenced by Run().
void Thread::Sleep | ( | System::Second | seconds, | |
System::Microsecond | microseconds = 0 | |||
) | [static] |
Makes the calling thread sleep during specified time.
seconds | the number of seconds to wait. | |
microseconds | the number of microseconds to wait, must be less than one second, it is only the remainder of the total wanted duration. |
ThreadException | if the sleep failed. |
Definition at line 497 of file CeylanThread.cc.
References Ceylan::System::basicSleep(), dataUtils::e, Ceylan::Exception::toString(), and Ceylan::toString().
Referenced by Ceylan::System::InputStream::Select().
virtual void Ceylan::System::Thread::start | ( | ) | [pure virtual] |
bool Thread::stopDemanded | ( | ) | const |
Tells whether the thread has been asked to stop.
Definition at line 395 of file CeylanThread.cc.
References _mustStop.
void Thread::threadCreationFailed | ( | int | error | ) | [protected, virtual] |
Called whenever the thread creation fails.
Definition at line 792 of file CeylanThread.cc.
References Ceylan::System::explainError().
Referenced by run().
const std::string TextDisplayable::ToString | ( | std::list< TextDisplayable * > | displayables, | |
Ceylan::VerbosityLevels | level = Ceylan::high | |||
) | [static, inherited] |
Returns a user-friendly description of this list of pointers to text displayable instances.
displayables | a list of pointers to TextDisplayable instances/ | |
level | the requested verbosity level. |
Definition at line 45 of file CeylanTextDisplayable.cc.
References Ceylan::formatStringList().
const string Thread::toString | ( | Ceylan::VerbosityLevels | level = Ceylan::high |
) | const [virtual] |
Returns a user-friendly description of the state of this object.
level | the requested verbosity level. |
Implements Ceylan::System::Runnable.
Definition at line 425 of file CeylanThread.cc.
References _clean, _id, _mustStop, _Number, _running, _terminated, Ceylan::formatStringList(), Ceylan::low, and Ceylan::medium.
void Thread::waitUntilOver | ( | ) |
Definition at line 404 of file CeylanThread.cc.
References _id, and Ceylan::System::Runnable::getName().
SystemSpecificThreadAttribute* Ceylan::System::Thread::_attr [private] |
Ceylan::System::Synchronized<bool> Ceylan::System::Thread::_clean [private] |
Tells whether this thread is clean, i.e.
if its cleanup
method has already been called.
Definition at line 627 of file CeylanThread.h.
Referenced by cleanup(), isClean(), and toString().
SystemSpecificThreadIdentifier* Ceylan::System::Thread::_id [private] |
This thread's unique system-specific identifier.
Definition at line 581 of file CeylanThread.h.
Referenced by cancel(), id(), run(), Thread(), toString(), waitUntilOver(), and ~Thread().
Ceylan::System::Synchronized<bool> Ceylan::System::Thread::_mustStop [private] |
Tells whether this thread must stop, i.e.
wheter it has been requested to do so.
Definition at line 644 of file CeylanThread.h.
Referenced by askToStop(), stopDemanded(), and toString().
Synchronized< ThreadCount > * Thread::_Number = 0 [static, private] |
Number of the currently existing thread instances.
Definition at line 654 of file CeylanThread.h.
Referenced by GetNumberOfThreads(), toString(), and ~Thread().
TextDisplayable::TextOutputFormat TextDisplayable::_OutputFormat = rawText [static, protected, inherited] |
The text format to be used currently by TextDisplayable instances.
Definition at line 158 of file CeylanTextDisplayable.h.
Referenced by Ceylan::TextDisplayable::GetOutputFormat(), and Ceylan::TextDisplayable::SetOutputFormat().
Ceylan::System::Synchronized<bool> Ceylan::System::Thread::_running [private] |
Tells whether this thread is currently running.
Definition at line 635 of file CeylanThread.h.
Referenced by cancel(), isRunning(), setRunning(), and toString().
Ceylan::System::Synchronized<bool> Ceylan::System::Thread::_terminated [private] |
Tells whether this thread has terminated, i.e.
if its cancel
method has already been called.
Definition at line 618 of file CeylanThread.h.
Referenced by cancel(), hasTerminated(), and toString().