version 1.36, 2003/04/16 00:17:14
|
version 1.36.4.1, 2003/07/16 21:45:25
|
|
|
} | } |
| |
Boolean Thread::_signals_blocked = false; | Boolean Thread::_signals_blocked = false; |
|
// l10n |
|
PEGASUS_THREAD_KEY_TYPE Thread::_platform_thread_key; |
|
Boolean Thread::_key_initialized = false; |
|
|
| |
// for non-native implementations | // for non-native implementations |
#ifndef PEGASUS_THREAD_CLEANUP_NATIVE | #ifndef PEGASUS_THREAD_CLEANUP_NATIVE |
|
|
| |
#endif | #endif |
| |
|
// l10n start |
|
Thread * Thread::getCurrent() |
|
{ |
|
PEG_METHOD_ENTER(TRC_THREAD, "ThreadPool::getCurrent"); |
|
if (!Thread::_key_initialized) |
|
return NULL; |
|
return (Thread *)pegasus_get_thread_specific(_platform_thread_key); |
|
} |
|
|
|
AcceptLanguages * Thread::getLanguages() |
|
{ |
|
PEG_METHOD_ENTER(TRC_THREAD, "ThreadPool::getLanguages"); |
|
|
|
Thread * curThrd = Thread::getCurrent(); |
|
if (curThrd == NULL) |
|
return NULL; |
|
AcceptLanguages * acceptLangs = |
|
(AcceptLanguages *)curThrd->reference_tsd("acceptLanguages"); |
|
curThrd->dereference_tsd(); |
|
PEG_METHOD_EXIT(); |
|
return acceptLangs; |
|
} |
|
|
|
void Thread::setLanguages(AcceptLanguages *langs) //l10n |
|
{ |
|
PEG_METHOD_ENTER(TRC_THREAD, "ThreadPool::setLanguages"); |
|
|
|
Thread * currentThrd = Thread::getCurrent(); |
|
if (currentThrd != NULL) |
|
{ |
|
// deletes the old tsd and creates a new one |
|
currentThrd->put_tsd("acceptLanguages", |
|
thread_data::default_delete, |
|
sizeof(AcceptLanguages *), |
|
langs); |
|
} |
|
|
|
PEG_METHOD_EXIT(); |
|
} |
|
|
|
void Thread::clearLanguages() //l10n |
|
{ |
|
PEG_METHOD_ENTER(TRC_THREAD, "ThreadPool::clearLanguages"); |
|
|
|
Thread * currentThrd = Thread::getCurrent(); |
|
if (currentThrd != NULL) |
|
{ |
|
// deletes the old tsd |
|
currentThrd->delete_tsd("acceptLanguages"); |
|
} |
|
|
|
PEG_METHOD_EXIT(); |
|
} |
|
// l10n end |
|
|
DQueue<ThreadPool> ThreadPool::_pools(true); | DQueue<ThreadPool> ThreadPool::_pools(true); |
| |
| |
|
|
} | } |
_pools.insert_last(this); | _pools.insert_last(this); |
| |
|
// l10n |
|
if (!Thread::_key_initialized) |
|
{ |
|
pegasus_key_create(&Thread::_platform_thread_key); |
|
Thread::_key_initialized = true; |
|
} |
} | } |
| |
| |
|
|
catch(...) | catch(...) |
{ | { |
} | } |
|
|
|
// l10n |
|
pegasus_key_delete(Thread::_platform_thread_key); |
} | } |
| |
// make this static to the class | // make this static to the class |
|
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
throw NullPointer(); | throw NullPointer(); |
} | } |
|
|
|
// l10n |
|
// Set myself into thread specific storage |
|
// This will allow code to get its own Thread |
|
pegasus_set_thread_specific(Thread::_platform_thread_key, (void *) myself); |
|
Tracer::trace(TRC_THREAD, Tracer::LEVEL4, |
|
"just set myself into thread specific storage"); |
|
|
ThreadPool *pool = (ThreadPool *)myself->get_parm(); | ThreadPool *pool = (ThreadPool *)myself->get_parm(); |
if(pool == 0 ) | if(pool == 0 ) |
{ | { |
|
|
{ | { |
gettimeofday(deadlock_timer, NULL); | gettimeofday(deadlock_timer, NULL); |
} | } |
|
|
gettimeofday(deadlock_timer, NULL); | gettimeofday(deadlock_timer, NULL); |
if( blocking_sem != 0 ) | if( blocking_sem != 0 ) |
blocking_sem->signal(); | blocking_sem->signal(); |
|
|
| |
th->put_tsd("deadlock timer", thread_data::default_delete, sizeof(struct timeval), (void *)dldt); | th->put_tsd("deadlock timer", thread_data::default_delete, sizeof(struct timeval), (void *)dldt); |
// thread will enter _loop(void *) and sleep on sleep_sem until we signal it | // thread will enter _loop(void *) and sleep on sleep_sem until we signal it |
|
|
th->run(); | th->run(); |
_current_threads++; | _current_threads++; |
pegasus_yield(); | pegasus_yield(); |
|
|
} | } |
| |
| |
|
|
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |
| |