Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / apps / JAWS3 / jaws3 / Concurrency.cpp
blobb637c86e406bf26b044247d5319208ee503fb1bb
1 #include "ace/OS_NS_strings.h"
2 #include "ace/Message_Block.h"
3 #include "ace/Singleton.h"
4 #include "ace/Synch_Traits.h"
5 #include "ace/Null_Mutex.h"
7 #ifndef JAWS_BUILD_DLL
8 #define JAWS_BUILD_DLL
9 #endif
11 #include "jaws3/Concurrency.h"
12 #include "jaws3/TPOOL_Concurrency.h"
13 #include "jaws3/TPR_Concurrency.h"
14 #include "jaws3/THYBRID_Concurrency.h"
15 #include "jaws3/Options.h"
18 typedef ACE_Singleton<ACE_Message_Block, ACE_SYNCH_NULL_MUTEX>
19 JAWS_Empty_Message_Block;
22 int
23 JAWS_Concurrency_Impl::svc ()
25 JAWS_Protocol_Handler *ph;
27 while (this->getq (ph) != -1)
29 if (ph == 0)
30 continue;
32 if (ph->service () == -1)
34 // TODO: Do I really want to call close here, or
35 // let the protocol handler close itself?
36 ph->dismiss ();
37 continue;
41 return 0;
45 JAWS_Concurrency_Bridge<JAWS_Concurrency_Impl>
46 ::JAWS_Concurrency_Bridge (JAWS_Concurrency_Impl *impl)
47 : impl_ (impl)
49 if (this->impl_ == 0)
51 const char *concurrency;
52 concurrency = JAWS_Options::instance ()->getenv ("JAWS_CONCURRENCY");
53 if (concurrency == 0)
54 concurrency = JAWS_DEFAULT_CONCURRENCY;
56 if (ACE_OS::strcasecmp (concurrency, "TPR") == 0)
57 this->impl_ = JAWS_TPR_Concurrency::instance ();
58 else if (ACE_OS::strcasecmp (concurrency, "TPOOL") == 0)
59 this->impl_ = JAWS_TPOOL_Concurrency::instance ();
60 else if (ACE_OS::strcasecmp (concurrency, "THYBRID") == 0)
61 this->impl_ = JAWS_THYBRID_Concurrency::instance ();
62 else
63 this->impl_ = JAWS_THYBRID_Concurrency::instance ();
64 // Since synchronous IO is the default IO, need an aggressive
65 // default concurrency mechanism.
70 int
71 JAWS_Concurrency_Bridge<JAWS_Concurrency_Impl>
72 ::putq (JAWS_Protocol_Handler *ph)
74 return this->impl_->putq (ph);
78 int
79 JAWS_Concurrency_Bridge<JAWS_Concurrency_Impl>
80 ::getq (JAWS_Protocol_Handler *&ph)
82 return this->impl_->getq (ph);
86 void
87 JAWS_Concurrency_Bridge<JAWS_Concurrency_Impl>::shutdown ()
89 ACE_Message_Block *empty_mb = JAWS_Empty_Message_Block::instance ();
90 JAWS_CONCURRENCY_TASK *task;
92 task = JAWS_THYBRID_Concurrency::instance ();
93 task->putq (empty_mb);
94 task->wait ();
96 task = JAWS_TPOOL_Concurrency::instance ();
97 task->putq (empty_mb);
98 task->wait ();
100 task = JAWS_TPR_Concurrency::instance ();
101 task->putq (empty_mb);
102 task->wait ();