Scopira 20080306

scopira::tool::thread Class Reference

#include <thread_pthreads.h>

Inheritance diagram for scopira::tool::thread:
scopira::tool::job_i scopira::tool::runnable_i scopira::tool::job_i scopira::tool::runnable_i scopira::tool::object scopira::tool::object scopira::tool::object scopira::tool::object

List of all members.

Classes

class  myQThread

Public Types

typedef pthread_key_t tlskey_t
typedef int tlskey_t

Public Member Functions

 thread (runnable_i *target)
 thread (runfunc_t func, void *arg)
virtual ~thread ()
 destructor
virtual void run (void)
 the run core
virtual void start (void)
 starts the actually execution of the thread and its run core
virtual void notify_stop (void)
virtual void wait_stop (void)
 suspeds caller until this thread stops
virtual bool is_running (void) const
 is this thread currently running?
 thread (runnable_i *target)
 thread (runfunc_t func, void *arg)
virtual ~thread ()
 destructor
virtual void run (void)
 the run core
virtual void start (void)
 starts the actually execution of the thread and its run core
virtual void notify_stop (void)
virtual void wait_stop (void)
 suspeds caller until this thread stops
virtual bool is_running (void) const
 is this thread currently running?

Static Public Member Functions

static void sleep (int msec)
static void open_tls (tlskey_t &outkey)
static void close_tls (tlskey_t k)
static void set_tls (tlskey_t k, const void *val)
static void * get_tls (tlskey_t k)
static void sleep (int msec)
static void open_tls (tlskey_t &outkey)
static void close_tls (tlskey_t k)
static void set_tls (tlskey_t k, void *val)
static void * get_tls (tlskey_t k)

Static Protected Member Functions

static void * voidrun (void *arg)

Protected Attributes

runnable_idm_target
runfunc_t dm_runfunc
void * dm_runfunc_arg
volatile bool dm_running
pthread_t dm_thread
scopira::tool::thread::myQThread dm_thread

Detailed Description

An operating system thread object.

Author:
Aleksander Demko

Constructor & Destructor Documentation

scopira::tool::thread::thread ( runnable_i target)

runnable_i Constructor.

If you pass a non-null target, that target's run method will be executed on start().

If you pass null, this->run() will be run, so you should descendat from thread and override it to make it do something.

Parameters:
targetthe runnable target
Author:
Aleksander Demko
scopira::tool::thread::thread ( runfunc_t  func,
void *  arg 
)

function pointer constructor. This version uses a function with argument instead runnable_i objects.

Parameters:
functhe runfunc_t... it should return 0
argthe argument that is passed to your function... this should be a this object or something, probably. This may be null (heck, it doesn't even have to be a valid pointer...)
Author:
Aleksander Demko
scopira::tool::thread::thread ( runnable_i target)

runnable_i Constructor.

If you pass a non-null target, that target's run method will be executed on start().

If you pass null, this->run() will be run, so you should descendat from thread and override it to make it do something.

Parameters:
targetthe runnable target
Author:
Aleksander Demko
scopira::tool::thread::thread ( runfunc_t  func,
void *  arg 
)

function pointer constructor. This version uses a function with argument instead runnable_i objects.

Parameters:
functhe runfunc_t... it should return 0
argthe argument that is passed to your function... this should be a this object or something, probably. This may be null (heck, it doesn't even have to be a valid pointer...)
Author:
Aleksander Demko

Member Function Documentation

static void scopira::tool::thread::close_tls ( tlskey_t  k) [static]

close a TLS slot in all thread instances.

Author:
Aleksander Demko
static void scopira::tool::thread::close_tls ( tlskey_t  k) [static]

close a TLS slot in all thread instances.

Author:
Aleksander Demko
static void* scopira::tool::thread::get_tls ( tlskey_t  k) [static]

Get a TLS slot of the CURRENT thread. TLS data values default to null (0). Please note that this applies to the active thread, and may not be directed at individual thread objects.

Author:
Aleksander Demko
static void* scopira::tool::thread::get_tls ( tlskey_t  k) [static]

Get a TLS slot of the CURRENT thread. TLS data values default to null (0). Please note that this applies to the active thread, and may not be directed at individual thread objects.

Author:
Aleksander Demko
virtual void scopira::tool::thread::notify_stop ( void  ) [virtual]

doesnt actually do anything descendant classes might want to implement something if convinient

Implements scopira::tool::job_i.

virtual void scopira::tool::thread::notify_stop ( void  ) [virtual]

doesnt actually do anything descendant classes might want to implement something if convinient

Implements scopira::tool::job_i.

static void scopira::tool::thread::open_tls ( tlskey_t &  outkey) [static]

opens a TLS (thread local storage) slot in all current and future threads. You must call this once before doing any set/get calls. The initial value of the storage in each thread instance will be 0 (null).

outkey is where the new key is stored.

Author:
Aleksander Demko
static void scopira::tool::thread::open_tls ( tlskey_t &  outkey) [static]

opens a TLS (thread local storage) slot in all current and future threads. You must call this once before doing any set/get calls. The initial value of the storage in each thread instance will be 0 (null).

outkey is where the new key is stored.

Author:
Aleksander Demko
static void scopira::tool::thread::set_tls ( tlskey_t  k,
void *  val 
) [static]

Set a TLS slot of the CURRENT thread. TLS data values default to null (0). Please note that this applies to the active thread, and may not be directed at individual thread objects.

Author:
Aleksander Demko
static void scopira::tool::thread::set_tls ( tlskey_t  k,
const void *  val 
) [static]

Set a TLS slot of the CURRENT thread. TLS data values default to null (0). Please note that this applies to the active thread, and may not be directed at individual thread objects.

Author:
Aleksander Demko
static void scopira::tool::thread::sleep ( int  msec) [static]

cause the current thread to sleep

Parameters:
msecthe number of msec (1000=second) to wait
Returns:
true if got a notification event, false if timed out
static void scopira::tool::thread::sleep ( int  msec) [static]

cause the current thread to sleep

Parameters:
msecthe number of msec (1000=second) to wait
Returns:
true if got a notification event, false if timed out

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