version 1.52, 2005/06/20 13:12:51
|
version 1.53, 2005/06/24 19:34:23
|
|
|
}; | }; |
| |
| |
|
enum ThreadStatus { |
|
PEGASUS_THREAD_OK = 1, /* No problems */ |
|
PEGASUS_THREAD_INSUFFICIENT_RESOURCES, /* Can't allocate a thread. Not enough |
|
memory. Try again later */ |
|
PEGASUS_THREAD_SETUP_FAILURE, /* Could not allocate into the thread specific |
|
data storage. */ |
|
PEGASUS_THREAD_UNAVAILABLE /* Service is being destroyed and no new threads can |
|
be provided. */ |
|
}; |
|
|
/////////////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////////////// |
| |
class PEGASUS_COMMON_LINKAGE Thread | class PEGASUS_COMMON_LINKAGE Thread |
{ | { |
|
|
public: | public: |
|
|
Thread( PEGASUS_THREAD_RETURN (PEGASUS_THREAD_CDECL *start )(void *), | Thread( PEGASUS_THREAD_RETURN (PEGASUS_THREAD_CDECL *start )(void *), |
void *parameter, Boolean detached ); | void *parameter, Boolean detached ); |
| |
|
|
| |
/** | /** |
Start the thread. | Start the thread. |
@return true if the thread is started successfully, false if the |
@return PEGASUS_THREAD_OK if the thread is started successfully, |
resources necessary to start the thread are not currently |
PEGASUS_THREAD_INSUFFICIENT_RESOURCES if the resources necessary |
available. ATTN: The result is undefined for any other |
to start the thread are not currently available. |
type of failure. (See Bugzilla 972) |
PEGASUS_THREAD_SETUP_FAILURE if the thread could not |
|
be create properly - check the 'errno' value for specific operating |
|
system return code. |
*/ | */ |
Boolean run(); |
ThreadStatus run(); |
| |
// get the user parameter | // get the user parameter |
inline void *get_parm() { return _thread_parm; } | inline void *get_parm() { return _thread_parm; } |
|
|
@param blocking A pointer to an optional semaphore which, if | @param blocking A pointer to an optional semaphore which, if |
specified, is signaled after the thread finishes | specified, is signaled after the thread finishes |
executing the work function | executing the work function |
@return true if the thread is started successfully, false if the |
@return PEGASUS_THREAD_OK if the thread is started successfully, |
|
PEGASUS_THREAD_INSUFFICIENT_RESOURCES if the |
resources necessary to start the thread are not currently | resources necessary to start the thread are not currently |
available. ATTN: The result is undefined for any other |
available. PEGASUS_THREAD_SETUP_FAILURE if the thread |
type of thread creation failure. |
could not be setup properly. PEGASUS_THREAD_UNAVAILABLE |
|
if this service is shutting down and no more threads can |
|
be allocated. |
@exception IPCException | @exception IPCException |
*/ | */ |
Boolean allocate_and_awaken( |
ThreadStatus allocate_and_awaken( |
void* parm, | void* parm, |
PEGASUS_THREAD_RETURN (PEGASUS_THREAD_CDECL* work)(void *), | PEGASUS_THREAD_RETURN (PEGASUS_THREAD_CDECL* work)(void *), |
Semaphore* blocking = 0); | Semaphore* blocking = 0); |