version 1.90.2.9, 2006/07/29 15:54:07
|
version 1.95, 2006/08/21 15:46:16
|
|
|
// | // |
//============================================================================== | //============================================================================== |
// | // |
// Author: Mike Day (mdday@us.ibm.com) |
|
// |
|
// Modified By: Rudy Schuet (rudy.schuet@compaq.com) 11/12/01 |
|
// added nsk platform support |
|
// Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) |
|
// Amit K Arora, IBM (amita@in.ibm.com) for PEP#101 |
|
// Sean Keenan, Hewlett-Packard Company (sean.keenan@hp.com) |
|
// David Dillard, VERITAS Software Corp. |
|
// (david.dillard@veritas.com) |
|
// |
|
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
#include "Thread.h" | #include "Thread.h" |
|
|
void Thread::cancel() | void Thread::cancel() |
{ | { |
_cancelled = true; | _cancelled = true; |
pthread_cancel(_handle.thid.tt_handle()); |
pthread_cancel(_handle.thid.thread); |
} | } |
| |
void Thread::test_cancel() | void Thread::test_cancel() |
|
|
#if defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) | #if defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) |
void Thread::suspend() | void Thread::suspend() |
{ | { |
pthread_kill(_handle.thid.tt_handle(), SIGSTOP); |
pthread_kill(_handle.thid.thread, SIGSTOP); |
} | } |
| |
void Thread::resume() | void Thread::resume() |
{ | { |
pthread_kill(_handle.thid.tt_handle(), SIGCONT); |
pthread_kill(_handle.thid.thread, SIGCONT); |
} | } |
#endif | #endif |
| |
|
|
| |
void Thread::join(void) | void Thread::join(void) |
{ | { |
if (!_is_detached && Threads::id(_handle.thid) != 0) |
if (!_is_detached && !Threads::null(_handle.thid)) |
pthread_join(_handle.thid.tt_handle(), &_exit_code); |
pthread_join(_handle.thid.thread, &_exit_code); |
| |
Threads::clear(_handle.thid); | Threads::clear(_handle.thid); |
} | } |
|
|
void Thread::detach(void) | void Thread::detach(void) |
{ | { |
_is_detached = true; | _is_detached = true; |
pthread_detach(_handle.thid.tt_handle()); |
#if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) |
|
pthread_t thread_id=_handle.thid.thread; |
|
pthread_detach(&thread_id); |
|
#else |
|
pthread_detach(_handle.thid.thread); |
|
#endif |
} | } |
| |
ThreadStatus Thread::run() | ThreadStatus Thread::run() |
|
|
// are no insufficient memory. Hence we are checking for both. See bug | // are no insufficient memory. Hence we are checking for both. See bug |
// 386. | // 386. |
| |
|
if (rc == -1) |
|
rc = errno; |
if ((rc == EAGAIN) || (rc == ENOMEM)) | if ((rc == EAGAIN) || (rc == ENOMEM)) |
{ | { |
Threads::clear(_handle.thid); | Threads::clear(_handle.thid); |
|
|
// sigaddset(sig, SIGUSR1); | // sigaddset(sig, SIGUSR1); |
// sigaddset(sig, SIGUSR2); | // sigaddset(sig, SIGUSR2); |
// #endif | // #endif |
#ifndef PEGASUS_PLATFORM_ZOS_ZSERIES_IBM |
#if defined (PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined (PEGASUS_OS_VMS) |
pthread_sigmask(SIG_BLOCK, sig, NULL); |
|
#else |
|
sigprocmask(SIG_BLOCK, sig, NULL); | sigprocmask(SIG_BLOCK, sig, NULL); |
|
#else |
|
pthread_sigmask(SIG_BLOCK, sig, NULL); |
#endif | #endif |
return sig; | return sig; |
} | } |
|
|
tt.handle = (HANDLE) _beginthreadex(NULL, 0, _start, this, 0, &threadid); | tt.handle = (HANDLE) _beginthreadex(NULL, 0, _start, this, 0, &threadid); |
_handle.thid = tt; | _handle.thid = tt; |
| |
if (Threads::id(_handle.thid) == 0) |
if (Threads::null(_handle.thid)) |
{ | { |
if (errno == EAGAIN) | if (errno == EAGAIN) |
{ | { |
|
|
| |
void Thread::join(void) | void Thread::join(void) |
{ | { |
if (Threads::id(_handle.thid) != 0) |
if (!Threads::null(_handle.thid)) |
{ | { |
if (!_is_detached) | if (!_is_detached) |
{ | { |