Cleanup ACE_HAS_PTHREAD_SIGMASK_PROTOTYPE, all platforms support it so far as I can...
[ACE_TAO.git] / ACE / apps / JAWS3 / jaws3 / TPR_Concurrency.cpp
blob02af889d865128711dd352d3d15a480749bb7f9c
1 #include "ace/Message_Block.h"
3 #ifndef JAWS_BUILD_DLL
4 #define JAWS_BUILD_DLL
5 #endif
7 #include "jaws3/Concurrency.h"
8 #include "jaws3/TPR_Concurrency.h"
9 #include "jaws3/Protocol_Handler.h"
10 #include "jaws3/Options.h"
13 JAWS_TPR_Concurrency::JAWS_TPR_Concurrency ()
14 : getting_ (0)
15 , shutdown_task_ (0)
16 , error_ (0)
18 int r;
19 r = this->activate (THR_BOUND | THR_JOINABLE);
20 if (r < 0)
22 this->error_ = 1;
23 this->shutdown_task_ = 1;
27 int
28 JAWS_TPR_Concurrency::putq (JAWS_Protocol_Handler *ph)
30 if (this->error_)
31 return -1;
33 JAWS_CONCURRENCY_TASK *task = this;
34 int result = task->putq (& ph->mb_);
36 if (result != -1)
38 int r;
39 r = this->activate ( THR_BOUND | THR_JOINABLE
40 , 1 // number of threads
41 , 1 // force active
43 if (r < 0)
45 // ACE_ERROR
46 return -1;
50 return result;
53 int
54 JAWS_TPR_Concurrency::getq (JAWS_Protocol_Handler *&ph)
56 ph = 0;
58 JAWS_CONCURRENCY_TASK *task = this;
60 if (this->shutdown_task_ && task->msg_queue ()->message_count () == 0)
61 return -1;
63 int getting = ++(this->getting_);
65 if (getting > 1 && task->msg_queue ()->message_count () == 0)
67 --(this->getting_);
68 return -1;
71 ACE_Message_Block *mb = 0;
72 int result = task->getq (mb);
74 if (result != -1)
76 ph = (JAWS_Protocol_Handler *) mb->base ();
78 if (ph == 0)
80 // Shutdown this task;
81 this->shutdown_task_ = 1;
85 --(this->getting_);
86 return result;