#include <wefts_os_base.h>
Inheritance diagram for Wefts::OSThreadBase:
Public Member Functions | |
virtual bool | priority (OSPriority prio_class, int boost=0)=0 |
Sets thread priority. | |
virtual bool | start (void *(*func)(void *), void *data)=0 |
Starts OS specific thread OS dependant implementation must provide a valid function to execute the thread; Thread.cpp has already some valid ones. | |
virtual bool | stop ()=0 |
Stop this OS specific thread. | |
virtual void * | join ()=0 |
Joins this OS Specific threads. | |
virtual int | enableCancel ()=0 |
Enables cancellation: This function returns the old status on success, that can be later reset with setCancelStatus. | |
virtual int | disableCancel ()=0 |
Disables cancellation. | |
virtual bool | setCancelState (int state)=0 |
Raw function to set the cancel type. | |
virtual void | testCancel ()=0 |
Kill the thread on OS level cancellation. | |
virtual void | setCancelDeferred ()=0 |
Tells the thread that it must use deferred cancellation. | |
virtual void | detach ()=0 |
Detach thread. | |
virtual void | emuDeferredStart () |
Starts emulated deferred cancellation. | |
virtual void | emuDeferredEnd () |
End emulated deferred cancellation. | |
virtual void * | osRun (void *(*func)(void *), void *data, void(*cleanup)(void *))=0 |
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. | |
virtual bool | same () const =0 |
Returns true if the currently running thread and this objects are the same. | |
virtual bool | equal (const OSThreadBase &th) const =0 |
Returns true if this object is equal (on OS opinion) to the parameter. | |
virtual bool | setCurrent ()=0 |
Change this thread object to the current OS dependant thread. | |
virtual void | invalidate ()=0 |
virtual bool | operator== (OSThreadBase &th) |
Pass the test to equal(). | |
virtual bool | operator!= (OSThreadBase &th) |
Pass the test to ! equal(). | |
Protected Member Functions | |
OSThreadBase () | |
Newly created thread. | |
OSThreadBase (bool) | |
Already running thread. | |
virtual void | exit (void *data)=0 |
Exit the thread. |
|
Newly created thread. Subclassess must calll invalidate() member to specify that the current thread is still not running. |
|
Already running thread. Call this constructor if you need to have a reference to the thread that is currently running; this will set the OSThreadBase internal data as if a start were called at some point. |
|
Detach thread.
Implemented in Wefts::OSThreadPthread, and Wefts::OSThreadWindows. |
|
Disables cancellation. Wokrs like enableCancel.
Implemented in Wefts::OSThreadPthread, and Wefts::OSThreadWindows. |
|
End emulated deferred cancellation. In base class, it does nothing. If the os does support natively the deferred cancellation scheme, this function is useless.
|
|
Starts emulated deferred cancellation. In base class, it does nothing. If the os does support natively the deferred cancellation scheme, this function is useless.
|
|
Enables cancellation: This function returns the old status on success, that can be later reset with setCancelStatus. On error, return type is undefined.
Implemented in Wefts::OSThreadPthread, and Wefts::OSThreadWindows. |
|
Returns true if this object is equal (on OS opinion) to the parameter.
Implemented in Wefts::OSThreadPthread, and Wefts::OSThreadWindows. |
|
Exit the thread. Run() can call this method instead of retunring a void *; the effect is the same. Implemented in Wefts::OSThreadPthread, and Wefts::OSThreadWindows. |
|
Implemented in Wefts::OSThreadPthread, and Wefts::OSThreadWindows. |
|
Joins this OS Specific threads.
Implemented in Wefts::OSThreadPthread, and Wefts::OSThreadWindows. |
|
Pass the test to ! equal().
|
|
Pass the test to equal().
|
|
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. Paramere data is actually a Thread or derived class isntance, but it must be considered opaque to os layer. The parameter for clanup, that must be called inside this method, is must be a ThreadAndReturn structure, which contains a pointer to a Wefts::Thread or derived object, and the return value of the func parameter. Derived classes are responsible to fill correctly this structrue: the thread member of ThreadAndReturn must be set to the data parameter; before func is called, the runReturn element of the ThreadAndReturn structure must be set to zero, and then it must be set to func call return value. Currently func() is only a wrapper to call data->run(), but this may change in the future.
Implemented in Wefts::OSThreadPthread, and Wefts::OSThreadWindows. |
|
Sets thread priority. Thread priority is defined by a class and a boost throttle. System may implement this differently, or even ignore it, if there isn't any low level mean to determine thread priority; wefts itself does not enforce any priority, but it tries to get the OS to act as near as possible to the required class and thread boost. The thread class defines how the thread is rescheduled after a wait, or after a swap; the boost level is a value that tells the system scheduler to prefer some thread with respect to the others in the same thread class. The higher is the boost level, the better are the chance of the thread to be rescheduled before the same threads with lower boost. Boost value can also be negative, meaning that the thread may be scheduled less often than other threads in the same class having boost 0. Wefts will try to arrange the theoretical model of Wefts priorities (OSPriority ) into the available threading model and OS capabilties.
The method returns ture if the priority may be set, or false otherwise; on some systems, the request to set a priority may fail due the need for higher system privilege to do so. Implemented in Wefts::OSThreadPthread, and Wefts::OSThreadWindows. |
|
Returns true if the currently running thread and this objects are the same.
Implemented in Wefts::OSThreadPthread, and Wefts::OSThreadWindows. |
|
Tells the thread that it must use deferred cancellation. The OS may provide deferred cancellation schemes natively, or not. In the latter case, deferred cancellation must be emulated; See Cancellation Issues. When OS does not provides inbound deferred cancellation, this routine must do nothing. Implemented in Wefts::OSThreadPthread, and Wefts::OSThreadWindows. |
|
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.
Implemented in Wefts::OSThreadPthread, and Wefts::OSThreadWindows. |
|
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. Implemented in Wefts::OSThreadPthread, and Wefts::OSThreadWindows. |
|
Starts OS specific thread OS dependant implementation must provide a valid function to execute the thread; Thread.cpp has already some valid ones.
Implemented in Wefts::OSThreadPthread, and Wefts::OSThreadWindows. |
|
Stop this OS specific thread.
Implemented in Wefts::OSThreadPthread, and Wefts::OSThreadWindows. |
|
Kill the thread on OS level cancellation.
Implemented in Wefts::OSThreadPthread, and Wefts::OSThreadWindows. |