Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Wefts::OSThreadWindows Class Reference

Wraps Windows threads. More...

#include <wefts_os_windows.h>

Inheritance diagram for Wefts::OSThreadWindows:

Inheritance graph
[legend]
Collaboration diagram for Wefts::OSThreadWindows:

Collaboration graph
[legend]
List of all members.

Public Methods

 OSThreadWindows ()
 OSThreadWindows (bool val)
 ~OSThreadWindows ()
bool start (void *(*func)(void *), void *data)
 Starts OS specific thread OS dependant implementation must provide a valid function to execute the thread; Thread.cpp has already some valid ones.

bool stop ()
 Stop this OS specific thread.

void * join () throw ( NotJoinableError )
 Joins this OS Specific threads.

int enableCancel ()
 We support only deferred emulated cancelation.

int disableCancel ()
 We support only deferred emulated cancelation.

bool setCancelState (int state)
 Raw function to set the cancel type.

virtual void osRun (void(*func)(void *), void *data, void(*cleanup)(void *))
 Executes a procedure under the hood of a cleanup procedure This method requires the underlying OS threading system to set up a single cleanup procedure, execute the procedure "func" and then call the cleanup procedure; if the thread is canceled, os system must provide.

void testCancel ()
 Kill the thread on OS level cancelation.

void setCancelDeferred ()
 Always in emulated deferred mode.

void detach ()
 Detach thread.

void exit (void *data)
 Exit the thread.

bool same () const
 Returns true if the currently running thread and this objects are the same.

bool equal (const OSThreadBase &th) const
 Returns true if this object is equal (on OS opinion) to the parameter.

virtual bool setCurrent ()
 Change this thread object to the current OS dependant thread.

virtual void invalidate ()

Private Attributes

DWORD m_thid
 windows thread id

HANDLE m_hth
 Windows thread handle.

bool m_valid
 true if this thread is considered valid

HANDLE m_evtCancel
 Cancelation control.

bool m_wasCanceled
 Used to reset cancel event after a section where cancelation is disabled.

bool m_canCancel
 Kind cancelation control.

void(* m_rawCleanup )(void *)
 Pointer to thread raw cleanup function.

void * m_rawCleanData
 Pointer to thread raw cleanup data.


Friends

class OSConditionWindows
class OSFileFuncWin
bool OSSleep (long nSeconds, long nNanoseconds)
 Function to provide a wefts-interruptable wait.


Detailed Description

Wraps Windows threads.

See also:
OS Threading Abstraction (and Independence) Layer


Constructor & Destructor Documentation

Wefts::OSThreadWindows::OSThreadWindows  
 

Wefts::OSThreadWindows::OSThreadWindows bool    val [inline]
 

Wefts::OSThreadWindows::~OSThreadWindows  
 


Member Function Documentation

void Wefts::OSThreadWindows::detach   [inline, virtual]
 

Detach thread.

Note:
Wefts detaching differs from pthread detaching; a wefts detached thread is just a thread whose class data will be automatically destroyed on termination (and that can't be joined).
See also:
Thread::detach()

Implements Wefts::OSThreadBase.

int Wefts::OSThreadWindows::disableCancel   [virtual]
 

We support only deferred emulated cancelation.

Implements Wefts::OSThreadBase.

int Wefts::OSThreadWindows::enableCancel   [virtual]
 

We support only deferred emulated cancelation.

Implements Wefts::OSThreadBase.

bool Wefts::OSThreadWindows::equal const OSThreadBase   th const [inline, virtual]
 

Returns true if this object is equal (on OS opinion) to the parameter.

Implements Wefts::OSThreadBase.

void Wefts::OSThreadWindows::exit void *    data [virtual]
 

Exit the thread.

Run() can call this method instead of retunring a void *; the effect is the same.

Implements Wefts::OSThreadBase.

void Wefts::OSThreadWindows::invalidate   [virtual]
 

Implements Wefts::OSThreadBase.

void * Wefts::OSThreadWindows::join   throw ( NotJoinableError ) [virtual]
 

Joins this OS Specific threads.

Implements Wefts::OSThreadBase.

void Wefts::OSThreadWindows::osRun void(*    func)(void *),
void *    data,
void(*    cleanup)(void *)
[virtual]
 

Executes a procedure under the hood of a cleanup procedure This method requires the underlying OS threading system to set up a single cleanup procedure, execute the procedure "func" and then call the cleanup procedure; if the thread is canceled, os system must provide.

"data" to the cleanup procedure and exit cleanly.

Data is actually a Wefts::Thread or derived object, but the data must be considered opaque to os layer.

Currently func() is only a wrapper to call data->run(), but this may change in the future.

Implements Wefts::OSThreadBase.

bool Wefts::OSThreadWindows::same   [inline, virtual]
 

Returns true if the currently running thread and this objects are the same.

Implements Wefts::OSThreadBase.

void Wefts::OSThreadWindows::setCancelDeferred   [inline, virtual]
 

Always in emulated deferred mode.

Implements Wefts::OSThreadBase.

bool Wefts::OSThreadWindows::setCancelState int    state [inline, virtual]
 

Raw function to set the cancel type.

This function should be used only with the integer returned by enableCancel() and disableCancel(), as no assumption can be made about what the meaning of the parameter could be in different environments.

Parameters:
state  system dependant (that is to say: don't touch it).
Returns:
true on success

Implements Wefts::OSThreadBase.

bool Wefts::OSThreadWindows::setCurrent   [virtual]
 

Change this thread object to the current OS dependant thread.

It makes so that all the internal variables are set to reflect this current thread. In some implementation, updating of some variables my be deferred to a later moment; the important thing is to change the thread type.

Implements Wefts::OSThreadBase.

bool Wefts::OSThreadWindows::start void *(*    func)(void *),
void *    data
[virtual]
 

Starts OS specific thread OS dependant implementation must provide a valid function to execute the thread; Thread.cpp has already some valid ones.

Parameters:
func  the function to be executed in parallel thread.
data  the data to be passed to os-level thread function

Implements Wefts::OSThreadBase.

bool Wefts::OSThreadWindows::stop   [virtual]
 

Stop this OS specific thread.

Implements Wefts::OSThreadBase.

void Wefts::OSThreadWindows::testCancel   [virtual]
 

Kill the thread on OS level cancelation.

Implements Wefts::OSThreadBase.


Friends And Related Function Documentation

friend class OSConditionWindows [friend]
 

friend class OSFileFuncWin [friend]
 

bool OSSleep long    nSeconds,
long    nNanoseconds
[friend]
 

Function to provide a wefts-interruptable wait.


Member Data Documentation

bool Wefts::OSThreadWindows::m_canCancel [private]
 

Kind cancelation control.

HANDLE Wefts::OSThreadWindows::m_evtCancel [private]
 

Cancelation control.

HANDLE Wefts::OSThreadWindows::m_hth [private]
 

Windows thread handle.

void* Wefts::OSThreadWindows::m_rawCleanData [private]
 

Pointer to thread raw cleanup data.

This pointer holds generally a pointer to a Wefts::Thread or subclass, and is initializated in osRun() by functions in wefts_thread.c

void(* Wefts::OSThreadWindows::m_rawCleanup)(void *) [private]
 

Pointer to thread raw cleanup function.

This function is usually defined in wefts_thread.c and has the duty to call the high-level thread layer.

DWORD Wefts::OSThreadWindows::m_thid [private]
 

windows thread id

bool Wefts::OSThreadWindows::m_valid [private]
 

true if this thread is considered valid

bool Wefts::OSThreadWindows::m_wasCanceled [private]
 

Used to reset cancel event after a section where cancelation is disabled.

disableCancel will set this to true if the event that commands the thread to be canceled was set. Then if enableCancel is issued, the event is set again if it was set before.


The documentation for this class was generated from the following files:
Generated on Mon Dec 22 04:12:39 2003 for Wefts by doxygen1.2.18