summaryrefslogtreecommitdiff
path: root/ace
diff options
context:
space:
mode:
authornanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-09-14 07:08:33 +0000
committernanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-09-14 07:08:33 +0000
commit37981beb729b19337051eb79306b811b1a719641 (patch)
tree190d855d9e6d4fce16a7d9e2ef883a6c868e9efa /ace
parent383b1f9f3a1bc9af2305065c4ba80833aaa8ecb4 (diff)
downloadATCD-37981beb729b19337051eb79306b811b1a719641.tar.gz
Added ACE_Thread_Pool_Strategy and AE_Svc_Handler_Pool_Strategy
Diffstat (limited to 'ace')
-rw-r--r--ace/Strategies_T.cpp22
-rw-r--r--ace/Strategies_T.h67
-rw-r--r--ace/Strategies_T.i37
3 files changed, 126 insertions, 0 deletions
diff --git a/ace/Strategies_T.cpp b/ace/Strategies_T.cpp
index 63ad3f9332c..170af695e00 100644
--- a/ace/Strategies_T.cpp
+++ b/ace/Strategies_T.cpp
@@ -221,6 +221,20 @@ ACE_Thread_Strategy<SVC_HANDLER>::activate_svc_handler (SVC_HANDLER *svc_handler
return svc_handler->activate (this->thr_flags_, this->n_threads_);
}
+template <class SVC_HANDLER> int
+ACE_Thread_Pool_Strategy<SVC_HANDLER>::activate_svc_handler (SVC_HANDLER *svc_handler,
+ void *arg)
+{
+ ACE_TRACE ("ACE_Thread_Pool_Strategy<SVC_HANDLER>::activate_svc_handler");
+ // Call up to our parent to do the SVC_HANDLER initialization.
+ if (this->inherited::activate_svc_handler (svc_handler, arg) == -1)
+ return -1;
+ else
+ // Turn the <svc_handler> into an active object (if it isn't
+ // already one as a result of the first activation...)
+ return svc_handler->svc ();
+}
+
template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1>
ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Accept_Strategy
(const ACE_PEER_ACCEPTOR_ADDR &local_addr,
@@ -636,6 +650,12 @@ ACE_Thread_Strategy<SVC_HANDLER>::dump (void) const
ACE_TRACE ("ACE_Thread_Strategy<SVC_HANDLER>::dump");
}
+template <class SVC_HANDLER> void
+ACE_Thread_Pool_Strategy<SVC_HANDLER>::dump (void) const
+{
+ ACE_TRACE ("ACE_Thread_Pool_Strategy<SVC_HANDLER>::dump");
+}
+
template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> void
ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::dump (void) const
{
@@ -693,9 +713,11 @@ ACE_Creation_Strategy<SVC_HANDLER>::dump (void) const
ACE_ALLOC_HOOK_DEFINE(ACE_Creation_Strategy)
ACE_ALLOC_HOOK_DEFINE(ACE_Singleton_Strategy)
+ACE_ALLOC_HOOK_DEFINE(ACE_Svc_Handler_Pool_Strategy)
ACE_ALLOC_HOOK_DEFINE(ACE_DLL_Strategy)
ACE_ALLOC_HOOK_DEFINE(ACE_Concurrency_Strategy)
ACE_ALLOC_HOOK_DEFINE(ACE_Thread_Strategy)
+ACE_ALLOC_HOOK_DEFINE(ACE_Thread_Pool_Strategy)
ACE_ALLOC_HOOK_DEFINE(ACE_Connect_Strategy)
ACE_ALLOC_HOOK_DEFINE(ACE_Process_Strategy)
ACE_ALLOC_HOOK_DEFINE(ACE_Accept_Strategy)
diff --git a/ace/Strategies_T.h b/ace/Strategies_T.h
index bb8f69bd08f..5c17c90f112 100644
--- a/ace/Strategies_T.h
+++ b/ace/Strategies_T.h
@@ -183,6 +183,36 @@ protected:
};
template <class SVC_HANDLER>
+class ACE_Svc_Handler_Pool_Strategy : public ACE_Creation_Strategy<SVC_HANDLER>
+{
+ // = TITLE
+ // Defines the interface for specifying a creation strategy for
+ // a <SVC_HANDLER> that always returns the same <SVC_HANDLER> (i.e.,
+ // it's a Singleton).
+ //
+ // = DESCRIPTION
+ // Yadda, yadda... Unfinished...
+ // Note that this class takes over the ownership of the
+ // SVC_HANDLER passed into it as a parameter and it becomes
+ // responsible for deleting this object.
+public:
+ // = Initialization and termination methods.
+ ACE_Svc_Handler_Pool_Strategy (ACE_Thread_Manager * = 0);
+ virtual ~ACE_Svc_Handler_Pool_Strategy (void);
+
+ // = Factory method.
+ virtual int make_svc_handler (SVC_HANDLER *&);
+ // Create a Singleton SVC_HANDLER by always returning the same
+ // SVC_HANDLER. Returns -1 on failure, else 0.
+
+ void dump (void) const;
+ // Dump the state of an object.
+
+ ACE_ALLOC_HOOK_DECLARE;
+ // Declare the dynamic allocation hooks.
+};
+
+template <class SVC_HANDLER>
class ACE_Concurrency_Strategy
{
// = TITLE
@@ -334,6 +364,43 @@ protected:
};
template <class SVC_HANDLER>
+class ACE_Thread_Pool_Strategy : public ACE_Concurrency_Strategy<SVC_HANDLER>
+{
+ // = TITLE
+ // Defines the interface for specifying a concurrency strategy
+ // for a <SVC_HANDLER> based on multithreading.
+ //
+ // = DESCRIPTION
+ // This class provides a strategy that handle requests from
+ // clients concurrently using the current thread's context. It
+ // "activates" the user-supplied <SVC_HANDLER> by calling it's
+ // svc () method directly.
+public:
+ // = Intialization and termination methods.
+ ACE_Thread_Pool_Strategy (int flags = 0);
+ // "Do-nothing constructor"
+
+ virtual ~ACE_Thread_Pool_Strategy (void);
+
+ // = Factory method.
+ virtual int activate_svc_handler (SVC_HANDLER *svc_handler,
+ void *arg = 0);
+ // Activate the <svc_handler> with an appropriate concurrency
+ // strategy. This method activates the SVC_HANDLER by first calling
+ // its open() method and then calling its activate() method to turn
+ // it into an active object.
+
+ void dump (void) const;
+ // Dump the state of an object.
+
+ ACE_ALLOC_HOOK_DECLARE;
+ // Declare the dynamic allocation hooks.
+
+protected:
+ typedef ACE_Concurrency_Strategy<SVC_HANDLER> inherited;
+};
+
+template <class SVC_HANDLER>
class ACE_Process_Strategy : public ACE_Concurrency_Strategy<SVC_HANDLER>
{
// = TITLE
diff --git a/ace/Strategies_T.i b/ace/Strategies_T.i
index 7301dacf910..026d3afc899 100644
--- a/ace/Strategies_T.i
+++ b/ace/Strategies_T.i
@@ -53,6 +53,30 @@ ACE_Singleton_Strategy<SVC_HANDLER>::make_svc_handler (SVC_HANDLER *&sh)
return 0;
}
+template <class SVC_HANDLER> ASYS_INLINE
+ACE_Svc_Handler_Pool_Strategy<SVC_HANDLER>::ACE_Svc_Handler_Pool_Strategy (ACE_Thread_Manager *tm)
+{
+ ACE_TRACE ("ACE_Svc_Handler_Pool_Strategy<SVC_HANDLER>::ACE_Svc_Handler_Pool_Strategy");
+ this->open (tm);
+}
+
+template <class SVC_HANDLER> ASYS_INLINE
+ACE_Svc_Handler_Pool_Strategy<SVC_HANDLER>::~ACE_Svc_Handler_Pool_Strategy (void)
+{
+ ACE_TRACE ("ACE_Svc_Handler_Pool_Strategy<SVC_HANDLER>::~ACE_Svc_Handler_Pool_Strategy");
+}
+
+// Create a Singleton SVC_HANDLER by always returning the same
+// SVC_HANDLER.
+
+template <class SVC_HANDLER> ASYS_INLINE int
+ACE_Svc_Handler_Pool_Strategy<SVC_HANDLER>::make_svc_handler (SVC_HANDLER *&sh)
+{
+ ACE_TRACE ("ACE_Singleton_Strategy<SVC_HANDLER>::make_svc_handler");
+ ACE_NEW_RETURN (sh, SVC_HANDLER, 0);
+ return 0;
+}
+
template <class SVC_HANDLER> ASYS_INLINE int
ACE_Creation_Strategy<SVC_HANDLER>::open (ACE_Thread_Manager *thr_mgr)
{
@@ -178,6 +202,19 @@ ACE_Thread_Strategy<SVC_HANDLER>::~ACE_Thread_Strategy (void)
ACE_TRACE ("ACE_Thread_Strategy<SVC_HANDLER>::~ACE_Thread_Strategy");
}
+template <class SVC_HANDLER> ASYS_INLINE
+ACE_Thread_Pool_Strategy<SVC_HANDLER>::ACE_Thread_Pool_Strategy (int flags)
+ : ACE_Concurrency_Strategy<SVC_HANDLER> (flags)
+{
+ ACE_TRACE ("ACE_Thread_Pool_Strategy<SVC_HANDLER>::ACE_Thread_Strategy");
+}
+
+template <class SVC_HANDLER> ASYS_INLINE
+ACE_Thread_Pool_Strategy<SVC_HANDLER>::~ACE_Thread_Pool_Strategy (void)
+{
+ ACE_TRACE ("ACE_Thread_Pool_Strategy<SVC_HANDLER>::~ACE_Thread_Pool_Strategy");
+}
+
template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> ASYS_INLINE int
ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::open
(const ACE_PEER_ACCEPTOR_ADDR &local_addr, int restart)