int JAWS_THYBRID_Concurrency::putq (JAWS_Protocol_Handler *ph) { if (this->error_) return -1; JAWS_CONCURRENCY_TASK *task = this; int result = task->putq (& ph->mb_); if (result != -1) { if (this->getting_ < this->min_number_of_threads_ && (this->max_number_of_threads_ < 0 || this->thr_count () < (size_t) this->max_number_of_threads_)) { int r; r = this->activate ( THR_BOUND | THR_JOINABLE , 1 // number of threads , 1 // force active ); if (r < 0) { // ACE_ERROR return -1; } } } return result; }
int JAWS_TPOOL_Concurrency::getq (JAWS_Protocol_Handler *&ph) { ph = 0; JAWS_CONCURRENCY_TASK *task = this; if (this->shutdown_task_ && task->msg_queue ()->message_count () == 0) return -1; ACE_Message_Block *mb = 0; int result = task->getq (mb); if (result != -1) { ph = (JAWS_Protocol_Handler *) mb->base (); if (ph == 0) { // Shutdown this task; this->shutdown_task_ = 1; if (this->number_of_threads_ && this->number_of_threads_-- > 1) { task->putq (mb); result = -1; } } } return result; }
int JAWS_TPOOL_Concurrency::putq (JAWS_Protocol_Handler *ph) { if (this->error_) return -1; JAWS_CONCURRENCY_TASK *task = this; return task->putq (& ph->mb_); }
template <class CONCURRENCY_IMPL> void JAWS_Concurrency_Bridge<CONCURRENCY_IMPL>::shutdown (void) { ACE_Message_Block *empty_mb = JAWS_Empty_Message_Block::instance (); JAWS_CONCURRENCY_TASK *task; task = this->impl_; task->putq (empty_mb); task->wait (); }
int JAWS_THYBRID_Concurrency::getq (JAWS_Protocol_Handler *&ph) { ph = 0; JAWS_CONCURRENCY_TASK *task = this; if (this->shutdown_task_ && task->msg_queue ()->message_count () == 0) return -1; int getting = ++(this->getting_); if (getting > this->min_number_of_threads_) { if (task->msg_queue ()->message_count () == 0) { --(this->getting_); return -1; } } ACE_Message_Block *mb = 0; int result = task->getq (mb); if (result != -1) { ph = (JAWS_Protocol_Handler *) mb->base (); if (ph == 0) { // Shutdown this task; this->shutdown_task_ = 1; if (this->getting_ > 1) { task->putq (mb); result = -1; } } } --(this->getting_); return result; }
void JAWS_Concurrency_Bridge<JAWS_Concurrency_Impl>::shutdown (void) { ACE_Message_Block *empty_mb = JAWS_Empty_Message_Block::instance (); JAWS_CONCURRENCY_TASK *task; task = JAWS_THYBRID_Concurrency::instance (); task->putq (empty_mb); task->wait (); task = JAWS_TPOOL_Concurrency::instance (); task->putq (empty_mb); task->wait (); task = JAWS_TPR_Concurrency::instance (); task->putq (empty_mb); task->wait (); }