Open Lighting Architecture  0.9.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
ola::thread::Thread Class Reference

Detailed Description

A thread object that can be subclassed.

Inheritance diagram for ola::thread::Thread:
ola::FilePreferenceSaverThread ola::http::HTTPServer ola::plugin::ftdidmx::FtdiDmxThread ola::plugin::gpio::GPIODriver ola::plugin::karate::KarateThread ola::plugin::opendmx::OpenDmxThread ola::plugin::spi::HardwareBackend ola::plugin::spi::SoftwareBackend ola::plugin::uartdmx::UartDmxThread ola::plugin::usbdmx::LibUsbThread ola::plugin::usbdmx::ThreadedUsbSender ola::plugin::usbpro::WidgetDetectorThread ola::thread::CallbackThread ola::thread::ConsumerThread ola::thread::SignalThread

Classes

struct  Options
 Thread options. More...

Public Member Functions

 Thread (const Options &options=Options())
 Create a new thread with the specified thread options.
virtual ~Thread ()
 Destructor.
virtual bool Start ()
 Start the thread and wait for the thread to be running.
virtual bool FastStart ()
 Start the thread and return immediately.
virtual bool Join (void *ptr=NULL)
 Join this thread.
bool IsRunning ()
 Check if the thread is running.
ThreadId Id () const
 Return the thread id.
std::string Name () const
 Return the thread name.

Static Public Member Functions

static ThreadId Self ()
 Returns the current thread's id.

Protected Member Functions

virtual void * Run ()=0
 The entry point for the new thread.

Constructor & Destructor Documentation

ola::thread::Thread::Thread ( const Options options = Options())
explicit

Create a new thread with the specified thread options.

Parameters
optionsthe thread's options

Member Function Documentation

bool ola::thread::Thread::FastStart ( )
virtual

Start the thread and return immediately.

Returns
true if the thread started, false otherwise.

Don't use this unless you know what you're doing, since it introduces a race condition with Join().

ThreadId ola::thread::Thread::Id ( ) const
inline

Return the thread id.

Returns
the thread id.
bool ola::thread::Thread::IsRunning ( )

Check if the thread is running.

Returns
true if the thread was running at some point in the past.

This is best-effort only, since the thread may stop after IsRunning() returns.

bool ola::thread::Thread::Join ( void *  ptr = NULL)
virtual

Join this thread.

Parameters
[out]ptrThe value returned from the thread.
Returns
false if the thread wasn't running or didn't stop, true otherwise.

Reimplemented in ola::FilePreferenceSaverThread, and ola::plugin::usbpro::WidgetDetectorThread.

std::string ola::thread::Thread::Name ( ) const
inline

Return the thread name.

Returns
the thread name.

This may differ from the name assigned with pthread_setname, since the latter has a limit of 16 characters.

virtual void* ola::thread::Thread::Run ( )
protectedpure virtual
static ThreadId ola::thread::Thread::Self ( )
inlinestatic

Returns the current thread's id.

Returns
the current thread's id.
bool ola::thread::Thread::Start ( )
virtual

Start the thread and wait for the thread to be running.

Returns
true if the thread started, false otherwise.

This will block until the thread is running. Use FastStart() if you don't want to block.


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