version 1.21, 2002/06/19 22:06:33
|
version 1.27, 2002/09/17 18:01:03
|
|
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
throw NullPointer(); | throw NullPointer(); |
} | } |
|
|
|
if(_work == |
|
(PEGASUS_THREAD_RETURN (PEGASUS_THREAD_CDECL *)(void *)) &_undertaker) |
|
{ |
|
_work(parm); |
|
} |
|
|
gettimeofday(deadlock_timer, NULL); | gettimeofday(deadlock_timer, NULL); |
try | try |
{ | { |
|
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
myself->exit_self(0); | myself->exit_self(0); |
} | } |
|
|
} | } |
// wait to be awakend by the thread pool destructor | // wait to be awakend by the thread pool destructor |
sleep_sem->wait(); | sleep_sem->wait(); |
|
|
int i = 0; | int i = 0; |
AtomicInt needed(0); | AtomicInt needed(0); |
| |
|
// for( ; i < 2; i++) << Fri Sep 13 12:49:46 2002 mdd >> |
|
// This change prevents the thread pool from killing hung threads. |
|
// The definition of a hung thread is one that has been on the run queue for too long. |
|
// "too long" is defined as a time interval that is set when the thread pool is created. |
|
// Cancelling "hung" threads has proved to be problematic. |
|
|
|
// With this change the thread pool will not cancel hung threads. This may prevent a |
|
// crash depending upon the state of the hung thread. It will cause the thread to hang |
|
// around and not do anything besides waste space. |
|
|
|
// Idle threads, those that have not executed a routine for a time interval, continue to be |
|
// destroyed. This is normal and should not cause any problems. |
|
|
for( ; i < 1; i++) | for( ; i < 1; i++) |
{ | { |
q = map[i]; | q = map[i]; |
|
|
} | } |
catch(...) | catch(...) |
{ | { |
|
q->unlock(); |
return bodies; | return bodies; |
} | } |
| |
|
|
} | } |
else | else |
{ | { |
check_time(&dt, get_deadlock_detect(&deadlock_timeout)); |
too_long = check_time(&dt, get_deadlock_detect(&deadlock_timeout)); |
} | } |
| |
if( true == too_long) | if( true == too_long) |
|
|
| |
if(sleep_sem == 0) | if(sleep_sem == 0) |
{ | { |
|
q->unlock(); |
th->dereference_tsd(); | th->dereference_tsd(); |
throw NullPointer(); | throw NullPointer(); |
} | } |
| |
// put the thread on the dead list | // put the thread on the dead list |
_dead.insert_first(th); |
//_dead.insert_first(th); |
bodies++; | bodies++; |
sleep_sem->signal(); | sleep_sem->signal(); |
| |
|
|
| |
Boolean ThreadPool::check_time(struct timeval *start, struct timeval *interval) | Boolean ThreadPool::check_time(struct timeval *start, struct timeval *interval) |
{ | { |
|
// never time out if the interval is zero |
|
if(interval && interval->tv_sec == 0 && interval->tv_usec == 0) |
|
return false; |
|
|
struct timeval now, finish, remaining; | struct timeval now, finish, remaining; |
Uint32 usec; | Uint32 usec; |
gettimeofday(&now, NULL); | gettimeofday(&now, NULL); |
|
|
myself->detach(); | myself->detach(); |
myself->_handle.thid = 0; | myself->_handle.thid = 0; |
myself->cancel(); | myself->cancel(); |
myself->test_cancel(); |
delete myself; |
myself->exit_self(0); |
Thread::test_cancel(); |
|
Thread::exit_self(0); |
} | } |
return((PEGASUS_THREAD_RETURN)0); | return((PEGASUS_THREAD_RETURN)0); |
} | } |