diff options
author | jxh <jxh@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-04-25 02:33:10 +0000 |
---|---|---|
committer | jxh <jxh@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-04-25 02:33:10 +0000 |
commit | ca0b43a2d9d9a09f98c11d2de55c80a98abd5b8a (patch) | |
tree | 2ae8ebec96e4530c62ee526589318d10bbbfa78d | |
parent | 238606655548c7590da3dc43ab7a62f42f4711d6 (diff) | |
download | ATCD-ca0b43a2d9d9a09f98c11d2de55c80a98abd5b8a.tar.gz |
Debugging!
-rw-r--r-- | apps/JAWS/PROTOTYPE/JAWS/IO.h | 3 | ||||
-rw-r--r-- | apps/JAWS/PROTOTYPE/JAWS/IO_Acceptor.cpp | 6 | ||||
-rw-r--r-- | apps/JAWS/PROTOTYPE/JAWS/IO_Acceptor.h | 6 | ||||
-rw-r--r-- | apps/JAWS/PROTOTYPE/JAWS/IO_Handler.h | 3 | ||||
-rw-r--r-- | apps/JAWS/PROTOTYPE/JAWS/Server.cpp | 54 | ||||
-rw-r--r-- | apps/JAWS/PROTOTYPE/JAWS/Server.h | 5 |
6 files changed, 49 insertions, 28 deletions
diff --git a/apps/JAWS/PROTOTYPE/JAWS/IO.h b/apps/JAWS/PROTOTYPE/JAWS/IO.h index e25d29a07ee..46dc24ff8c7 100644 --- a/apps/JAWS/PROTOTYPE/JAWS/IO.h +++ b/apps/JAWS/PROTOTYPE/JAWS/IO.h @@ -194,5 +194,8 @@ protected: // completes. }; +typedef ACE_Singleton<JAWS_Asynch_IO, ACE_SYNCH_MUTEX> + JAWS_Asynch_IO_Singleton; + #endif /* ACE_WIN32 */ #endif /* JAWS_IO_H */ diff --git a/apps/JAWS/PROTOTYPE/JAWS/IO_Acceptor.cpp b/apps/JAWS/PROTOTYPE/JAWS/IO_Acceptor.cpp index 731d9ccd1ab..cb80b35a226 100644 --- a/apps/JAWS/PROTOTYPE/JAWS/IO_Acceptor.cpp +++ b/apps/JAWS/PROTOTYPE/JAWS/IO_Acceptor.cpp @@ -32,7 +32,7 @@ JAWS_IO_Acceptor::accept (size_t) int JAWS_IO_Synch_Acceptor::open (const ACE_INET_Addr &local_sap) { - return this->acceptor_->open (local_sap); + return this->acceptor_.open (local_sap); } int @@ -42,8 +42,8 @@ JAWS_IO_Synch_Acceptor::accept (ACE_SOCK_Stream &new_stream, int restart, int reset_new_handle) const { - return this->acceptor_->accept (new_stream, remote_addr, timeout, - restart, reset_new_handle); + return this->acceptor_.accept (new_stream, remote_addr, timeout, + restart, reset_new_handle); } diff --git a/apps/JAWS/PROTOTYPE/JAWS/IO_Acceptor.h b/apps/JAWS/PROTOTYPE/JAWS/IO_Acceptor.h index 36b7b4fabb0..96bcdd9e37e 100644 --- a/apps/JAWS/PROTOTYPE/JAWS/IO_Acceptor.h +++ b/apps/JAWS/PROTOTYPE/JAWS/IO_Acceptor.h @@ -66,7 +66,7 @@ public: // Accept the connection private: - JAWS_IO_SOCK_Acceptor *acceptor_; + JAWS_IO_SOCK_Acceptor acceptor_; }; @@ -84,9 +84,7 @@ private: #if defined (ACE_WIN32) // This only works on Win32 platforms - ACE_Asynch_Acceptor<JAWS_IO_Handler> *acceptor_; -#else - void *acceptor_; + ACE_Asynch_Acceptor<JAWS_IO_Handler> acceptor_; #endif /* defined (ACE_WIN32) */ }; diff --git a/apps/JAWS/PROTOTYPE/JAWS/IO_Handler.h b/apps/JAWS/PROTOTYPE/JAWS/IO_Handler.h index 687b275ab20..919a6d2b51e 100644 --- a/apps/JAWS/PROTOTYPE/JAWS/IO_Handler.h +++ b/apps/JAWS/PROTOTYPE/JAWS/IO_Handler.h @@ -255,5 +255,8 @@ public: // the protocol }; +typedef ACE_Singleton<JAWS_Asynch_IO_Handler_Factory, ACE_SYNCH_MUTEX> + JAWS_Asynch_IO_Handler_Factory_Singleton; + #endif /* ACE_WIN32 */ #endif /* JAWS_IO_HANDLER_H */ diff --git a/apps/JAWS/PROTOTYPE/JAWS/Server.cpp b/apps/JAWS/PROTOTYPE/JAWS/Server.cpp index 3e183545010..eb19f75c607 100644 --- a/apps/JAWS/PROTOTYPE/JAWS/Server.cpp +++ b/apps/JAWS/PROTOTYPE/JAWS/Server.cpp @@ -5,6 +5,7 @@ #include "JAWS/Server.h" #include "JAWS/Data_Block.h" #include "JAWS/Concurrency.h" +#include "JAWS/IO.h" #include "JAWS/IO_Handler.h" #include "JAWS/IO_Acceptor.h" #include "JAWS/Pipeline_Tasks.h" @@ -42,19 +43,41 @@ JAWS_Server::init (int argc, char *argv[]) JAWS_Thread_Per_Singleton::instance ()->open (this->flags_, this->maxthreads_); + if (this->concurrency_ == 1) + this->policy_.concurrency (JAWS_Thread_Per_Singleton::instance ()); + else + this->policy_.concurrency (JAWS_Thread_Pool_Singleton::instance ()); + +#if !defined (ACE_WIN32) + this->dispatch_ = 0; +#endif /* !defined (ACE_WIN32) */ + + if (this->dispatch_ == 1) + { +#if defined (ACE_WIN32) + this->policy_.io (JAWS_Asynch_IO_Singleton::instance ()); + this->policy_.ioh_factory + (JAWS_Asynch_IO_Handler_Factory_Singleton::instance ()); + this->policy_.acceptor (JAWS_IO_Asynch_Acceptor_Singleton::instance ()); +#endif /* defined (ACE_WIN32) */ + } + else + { + this->policy_.io (JAWS_Synch_IO_Singleton::instance ()); + this->policy_.ioh_factory + (JAWS_Synch_IO_Handler_Factory_Singleton::instance ()); + this->policy_.acceptor (JAWS_IO_Synch_Acceptor_Singleton::instance ()); + } + } int -JAWS_Server::open (JAWS_Pipeline_Handler *protocol) +JAWS_Server::open (JAWS_Pipeline_Handler *protocol, + JAWS_Dispatch_Policy *policy) { - JAWS_Synch_IO_Handler_Factory synch_factory; -#if defined (ACE_WIN32) - JAWS_Asynch_IO_Handler_Factory asynch_factory; -#else - JAWS_Synch_IO_Handler_Factory &asynch_factory = synch_factory; -#endif /* defined (ACE_WIN32) */ + if (policy == 0) + policy = &this->policy_; - JAWS_IO_Handler_Factory *factory; JAWS_IO_Handler *handler; JAWS_Data_Block *db; @@ -63,11 +86,10 @@ JAWS_Server::open (JAWS_Pipeline_Handler *protocol) JAWS_IO_Asynch_Acceptor_Singleton::instance ()->open (inet_addr); // initialize an IO_Handler - factory = (this->dispatch_ == 0) ? &synch_factory : &asynch_factory; - handler = factory->create_io_handler (); + handler = policy->ioh_factory ()->create_io_handler (); if (handler == 0) { - factory->destroy_io_handler (handler); + policy->ioh_factory ()->destroy_io_handler (handler); ACE_DEBUG ((LM_DEBUG, "JAWS_Server::open, can't create handler\n")); return -1; } @@ -78,7 +100,7 @@ JAWS_Server::open (JAWS_Pipeline_Handler *protocol) db = new JAWS_Data_Block; if (db == 0) { - factory->destroy_io_handler (handler); + policy->ioh_factory ()->destroy_io_handler (handler); ACE_DEBUG ((LM_DEBUG, "JAWS_Server::open, can't create data block\n")); return -1; } @@ -91,13 +113,7 @@ JAWS_Server::open (JAWS_Pipeline_Handler *protocol) ACE_Message_Block mb (db); - JAWS_Concurrency_Base *concurrency; - concurrency = (this->concurrency_ == 0) - ? JAWS_Thread_Pool_Singleton::instance () - : JAWS_Thread_Per_Singleton::instance () - ; - - concurrency->put (&mb); + policy->concurrency ()->put (&mb); while (ACE_OS::thr_join (0, NULL) != -1) ; diff --git a/apps/JAWS/PROTOTYPE/JAWS/Server.h b/apps/JAWS/PROTOTYPE/JAWS/Server.h index e2405e4b360..34af4421b17 100644 --- a/apps/JAWS/PROTOTYPE/JAWS/Server.h +++ b/apps/JAWS/PROTOTYPE/JAWS/Server.h @@ -5,6 +5,7 @@ #define JAWS_SERVER_H #include "JAWS/Data_Block.h" +#include "JAWS/Policy.h" class JAWS_IO_Handler_Factory; @@ -15,7 +16,7 @@ public: JAWS_Server (int argc, char *argv[]); void init (int argc, char *argv[]); - int open (JAWS_Pipeline_Handler *ph); + int open (JAWS_Pipeline_Handler *ph, JAWS_Dispatch_Policy *dp = 0); private: void parse_args (int argc, char *argv[]); @@ -29,7 +30,7 @@ private: int maxthreads_; // maximum number of threads long flags_; // thread creation flags - JAWS_IO_Handler_Factory *factory_; + JAWS_Default_Dispatch_Policy policy_; }; |