UCommon
ucommon::DetachedThread Class Referenceabstract

A detached thread object that is stand-alone. More...

#include <thread.h>

Inheritance diagram for ucommon::DetachedThread:
Collaboration diagram for ucommon::DetachedThread:

Public Member Functions

void start (int priority=0)
 Start execution of detached context.
 
- Public Member Functions inherited from ucommon::Thread
bool isRunning (void) const
 
 operator bool () const
 
bool operator! () const
 
void setPriority (void)
 Set thread priority without disrupting scheduling if possible.
 
virtual ~Thread ()
 Destroy thread object, thread-specific data, and execution context.
 

Protected Member Functions

 DetachedThread (size_t size=0)
 Create a detached thread with a known context stack size.
 
void exit (void)
 Exit context of detached thread.
 
bool is_active (void) const
 Check if running.
 
virtual void run (void)=0
 Abstract interface for thread context run method.
 
 ~DetachedThread ()
 Destroys object when thread context exits.
 
- Protected Member Functions inherited from ucommon::Thread
void map (void)
 Map thread for get method.
 
 Thread (size_t stack=0)
 Create a thread object that will have a preset stack size.
 

Protected Attributes

bool active
 
- Protected Attributes inherited from ucommon::Thread
void * cancellor
 
int priority
 
enum ucommon::Thread:: { ... }  reserved
 
stacksize_t stack
 
pthread_t tid
 

Additional Inherited Members

- Static Public Member Functions inherited from ucommon::Thread
static size_t cache (void)
 Get cache line size.
 
static void concurrency (int level)
 Set concurrency level of process.
 
static bool equal (pthread_t thread1, pthread_t thread2)
 Determine if two thread identifiers refer to the same thread.
 
static Threadget (void)
 Get mapped thread object.
 
static void init (void)
 Used to initialize threading library.
 
static void policy (int polid)
 Used to specify scheduling policy for threads above priority "0".
 
static void release (void)
 
static pthread_t self (void)
 Get current thread id.
 
static void sleep (timeout_t timeout)
 Sleep current thread for a specified time period.
 
static void yield (void)
 Yield execution context of the current thread.
 
- Protected Types inherited from ucommon::Thread
enum  { R_UNUSED }
 

Detailed Description

A detached thread object that is stand-alone.

This object has no relationship with any other running thread instance will be automatically deleted when the running thread instance exits, either by it's run method exiting, or explicity calling the exit member function.

Author
David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org

Definition at line 887 of file thread.h.

Constructor & Destructor Documentation

◆ DetachedThread()

ucommon::DetachedThread::DetachedThread ( size_t size = 0)
protected

Create a detached thread with a known context stack size.

Parameters
sizeof stack for thread context or 0 for default.

◆ ~DetachedThread()

ucommon::DetachedThread::~DetachedThread ( )
protected

Destroys object when thread context exits.

Never externally deleted. Derived object may also have destructor to clean up thread-specific member data.

Member Function Documentation

◆ exit()

void ucommon::DetachedThread::exit ( void )
protectedvirtual

Exit context of detached thread.

Thread object will be deleted. This function should NO LONGER be called directly to exit a running thread. Instead, the thread should only "return" through the run() method to exit. The documented usage was changed so that exit() can still be used to modify the "delete this" behavior of detached threads while merging thread exit behavior with Mozilla NSPR.

Reimplemented from ucommon::Thread.

◆ is_active()

bool ucommon::DetachedThread::is_active ( void ) const
protectedvirtual

Check if running.

Reimplemented from ucommon::Thread.

◆ run()

virtual void ucommon::DetachedThread::run ( void )
protectedpure virtual

Abstract interface for thread context run method.

Implements ucommon::Thread.

◆ start()

void ucommon::DetachedThread::start ( int priority = 0)

Start execution of detached context.

This must be called after the object is created (perhaps with "new"). This method actually begins the new thread context, which then calls the object's run method.

Parameters
priorityto start thread with.

Field Documentation

◆ active

bool ucommon::DetachedThread::active
protected

Definition at line 893 of file thread.h.


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