org::xmlBlaster::util::thread::Thread Class Reference

Little framework for the abstraction of threads and thread related stuff. More...

Inheritance diagram for org::xmlBlaster::util::thread::Thread:

Inheritance graph
[legend]
Collaboration diagram for org::xmlBlaster::util::thread::Thread:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Thread ()
virtual ~Thread ()
virtual bool start (bool detached)
 When this method is invoked, the thread starts to run.
virtual void run ()=0
 This is the method which has to be implemented by the user.
virtual void join ()
 Joins the thread to the current thread, in other words, the it will wait until the thread on which this method is invoked, will terminate, before it continues.
bool isRunning () const

Static Public Member Functions

static void sleepNanos (org::xmlBlaster::util::Timestamp nanoSecondDelay)
 Sleeps the specified amount of time in nanoseconds.
static void sleep (long millis)
 Sleeps the specified amount of time in nanoseconds.
static void sleepSecs (long secs)
 Sleeps the specified amount of time in nanoseconds.
static org::xmlBlaster::util::Timestamp getCurrentTimestamp ()
 returns the current timestamp

Friends

class ThreadRunner

Detailed Description

Little framework for the abstraction of threads and thread related stuff.

Currently the implementation of threads and their synchronization is provided by boost::threads. Since some platforms have problems building this library we provided here an abstraction which makes it easy to switch to another implementation if needed.

This framework provides the following classes: ThreadRunner: only used internally by the class Thread. Thread: This class has a pure virtual method 'void run()' which must be implemented by the user. Mutex: The mutual exclusion class Condition: The class for wait and notify. Lock: used to lock a mutex. The constructor locks and the destructor unlocks.

Author:
Michele Laghi

Definition at line 58 of file ThreadBase.h.


Constructor & Destructor Documentation

org::xmlBlaster::util::thread::Thread::Thread (  ) 

virtual org::xmlBlaster::util::thread::Thread::~Thread (  )  [virtual]


Member Function Documentation

virtual bool org::xmlBlaster::util::thread::Thread::start ( bool  detached  )  [virtual]

When this method is invoked, the thread starts to run.

Note that you can not start a thread twice.

Returns:
true if the thread could be started, false otherwise.

Referenced by org::xmlBlaster::client::protocol::corba::CorbaDriverFactory::getDriverInstance(), org::xmlBlaster::util::EmbeddedServer::start(), and org::xmlBlaster::test::TestThread::testThread().

virtual void org::xmlBlaster::util::thread::Thread::run (  )  [pure virtual]

This is the method which has to be implemented by the user.

Implemented in org::xmlBlaster::util::EmbeddedServerRunner, org::xmlBlaster::util::Timeout, and org::xmlBlaster::test::TestThread.

static void org::xmlBlaster::util::thread::Thread::sleepNanos ( org::xmlBlaster::util::Timestamp  nanoSecondDelay  )  [static]

Sleeps the specified amount of time in nanoseconds.

static void org::xmlBlaster::util::thread::Thread::sleep ( long  millis  )  [static]

Sleeps the specified amount of time in nanoseconds.

Referenced by TestEmptyContent::execute(), MultiConnectDemo::execute(), HelloWorld2::execute(), PublishDemo::publish(), org::xmlBlaster::test::TestThread::run(), org::xmlBlaster::test::TestGet::tearDown(), org::xmlBlaster::test::TestFailsafe::testFailsafe(), org::xmlBlaster::test::TestSubXPath::testInitial(), org::xmlBlaster::test::TestFailsafe::testReconnect(), org::xmlBlaster::test::TestSub::testSubscribeSpecificCallback(), org::xmlBlaster::test::TestSuite::TestSuite(), SubscribeDemo::update(), and org::xmlBlaster::util::Timeout::~Timeout().

static void org::xmlBlaster::util::thread::Thread::sleepSecs ( long  secs  )  [static]

Sleeps the specified amount of time in nanoseconds.

Referenced by TestEmptyContent::execute(), SubscribeDemo::execute(), org::xmlBlaster::test::TestThread::run(), org::xmlBlaster::util::EmbeddedServer::start(), org::xmlBlaster::test::TestEmbeddedServer::testEmbeddedServer(), org::xmlBlaster::test::TestFailsafe::testFailsafe(), org::xmlBlaster::test::TestConnect::testPubSub(), org::xmlBlaster::test::TestFailsafe::testReconnect(), org::xmlBlaster::test::TestThread::testThread(), and org::xmlBlaster::test::TestTimeout::testTimeout().

static org::xmlBlaster::util::Timestamp org::xmlBlaster::util::thread::Thread::getCurrentTimestamp (  )  [static]

returns the current timestamp

Referenced by org::xmlBlaster::util::TimestampFactory::getTimestamp().

virtual void org::xmlBlaster::util::thread::Thread::join (  )  [virtual]

Joins the thread to the current thread, in other words, the it will wait until the thread on which this method is invoked, will terminate, before it continues.

Reimplemented in org::xmlBlaster::util::Timeout.

Referenced by org::xmlBlaster::util::Timeout::join(), org::xmlBlaster::client::protocol::corba::CorbaDriverFactory::killDriverInstance(), org::xmlBlaster::util::EmbeddedServer::stop(), org::xmlBlaster::client::protocol::corba::CorbaDriverFactory::~CorbaDriverFactory(), and org::xmlBlaster::test::TestThread::~TestThread().

bool org::xmlBlaster::util::thread::Thread::isRunning (  )  const

Definition at line 101 of file ThreadBase.h.


Friends And Related Function Documentation

friend class ThreadRunner [friend]

Definition at line 60 of file ThreadBase.h.


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