1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
// $Id: Concurrency.cpp 91813 2010-09-17 07:52:52Z johnnyw $
#include "ace/OS_NS_strings.h"
#include "ace/Message_Block.h"
#include "ace/Singleton.h"
#include "ace/Synch_Traits.h"
#include "ace/Null_Mutex.h"
#ifndef JAWS_BUILD_DLL
#define JAWS_BUILD_DLL
#endif
#include "jaws3/Concurrency.h"
#include "jaws3/TPOOL_Concurrency.h"
#include "jaws3/TPR_Concurrency.h"
#include "jaws3/THYBRID_Concurrency.h"
#include "jaws3/Options.h"
typedef ACE_Singleton<ACE_Message_Block, ACE_SYNCH_NULL_MUTEX>
JAWS_Empty_Message_Block;
int
JAWS_Concurrency_Impl::svc (void)
{
JAWS_Protocol_Handler *ph;
while (this->getq (ph) != -1)
{
if (ph == 0)
continue;
if (ph->service () == -1)
{
// TODO: Do I really want to call close here, or
// let the protocol handler close itself?
ph->dismiss ();
continue;
}
}
return 0;
}
JAWS_Concurrency_Bridge<JAWS_Concurrency_Impl>
::JAWS_Concurrency_Bridge (JAWS_Concurrency_Impl *impl)
: impl_ (impl)
{
if (this->impl_ == 0)
{
const char *concurrency;
concurrency = JAWS_Options::instance ()->getenv ("JAWS_CONCURRENCY");
if (concurrency == 0)
concurrency = JAWS_DEFAULT_CONCURRENCY;
if (ACE_OS::strcasecmp (concurrency, "TPR") == 0)
this->impl_ = JAWS_TPR_Concurrency::instance ();
else if (ACE_OS::strcasecmp (concurrency, "TPOOL") == 0)
this->impl_ = JAWS_TPOOL_Concurrency::instance ();
else if (ACE_OS::strcasecmp (concurrency, "THYBRID") == 0)
this->impl_ = JAWS_THYBRID_Concurrency::instance ();
else
this->impl_ = JAWS_THYBRID_Concurrency::instance ();
// Since synchronous IO is the default IO, need an aggressive
// default concurrency mechanism.
}
}
int
JAWS_Concurrency_Bridge<JAWS_Concurrency_Impl>
::putq (JAWS_Protocol_Handler *ph)
{
return this->impl_->putq (ph);
}
int
JAWS_Concurrency_Bridge<JAWS_Concurrency_Impl>
::getq (JAWS_Protocol_Handler *&ph)
{
return this->impl_->getq (ph);
}
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 ();
}
|