1 #include "ace/OS_NS_stdlib.h"
2 #include "ace/Message_Block.h"
8 #include "jaws3/TPOOL_Concurrency.h"
9 #include "jaws3/Protocol_Handler.h"
10 #include "jaws3/Options.h"
12 JAWS_TPOOL_Concurrency::JAWS_TPOOL_Concurrency ()
13 : number_of_threads_ (5)
17 const char *value
= JAWS_Options::instance ()->getenv ("JAWS_TPOOL_THREADS");
19 this->number_of_threads_
= ACE_OS::atoi (value
);
21 this->number_of_threads_
= ACE_OS::atoi (JAWS_DEFAULT_TPOOL_THREADS
);
23 if (this->number_of_threads_
<= 0)
24 this->number_of_threads_
= 5;
27 r
= this->activate ( THR_BOUND
| THR_JOINABLE
, this->number_of_threads_
);
33 this->shutdown_task_
= 1;
38 JAWS_TPOOL_Concurrency::putq (JAWS_Protocol_Handler
*ph
)
43 JAWS_CONCURRENCY_TASK
*task
= this;
44 return task
->putq (& ph
->mb_
);
48 JAWS_TPOOL_Concurrency::getq (JAWS_Protocol_Handler
*&ph
)
52 JAWS_CONCURRENCY_TASK
*task
= this;
54 if (this->shutdown_task_
&& task
->msg_queue ()->message_count () == 0)
57 ACE_Message_Block
*mb
= 0;
59 int result
= task
->getq (mb
);
63 ph
= (JAWS_Protocol_Handler
*) mb
->base ();
67 // Shutdown this task;
68 this->shutdown_task_
= 1;
69 if (this->number_of_threads_
&& this->number_of_threads_
-- > 1)