2 #ifndef JAWS_CONCURRENCY_H
3 #define JAWS_CONCURRENCY_H
5 #include "ace/config-all.h"
7 #if !defined (ACE_LACKS_PRAGMA_ONCE)
9 #endif /* ACE_LACKS_PRAGMA_ONCE */
14 class JAWS_Concurrency_Base
: public ACE_Task
<ACE_SYNCH
>
16 // Base class for different concurrency models
19 // Provides a default implementaion of the virtual put() method
20 // which calls putq(), but can be overloaded to do something
21 // synchronously, such as call put_next().
25 JAWS_Concurrency_Base ();
26 virtual int put (ACE_Message_Block
*mb
, ACE_Time_Value
*tv
= 0);
30 class JAWS_Dispatch_Policy
32 // Policy mechanism for choosing different concurrency models.
35 // Given some (unspecified) state, decides what the concurrency
36 // model should be. (For now, we always return the same model.)
39 JAWS_Dispatch_Policy ();
40 virtual ~JAWS_Dispatch_Policy ();
41 virtual JAWS_Concurrency_Base
* update (void *state
= 0) = 0;
46 // The class that is responsible to delivering events to the
47 // appropriate concurrency mechanism.
50 // JAWS_IO_Handler calls into the dispatcher so that the completed
51 // IO can find a thread to take care of it.
54 JAWS_Dispatcher (JAWS_Dispatch_Policy
*policy
);
56 int dispatch (JAWS_IO_Handler
*ioh
);
59 JAWS_Dispatch_Policy
*policy_
;
62 class JAWS_Thread_Pool_Task
: public JAWS_Concurrency_Base
64 // Used to implement Thread Pool Concurrency Strategy
67 // This task is created to hold a pool of threads that receive
68 // requests through the message queue.
71 JAWS_Thread_Pool_Task (long flags
= THR_NEW_LWP
,
80 class JAWS_Thread_Per_Task
: public JAWS_Concurrency_Base
82 // Used to implement Thread Per Request Concurrency Strategy
85 // As each new message arrives from the queue, a new thread is
86 // spawned to handle it. This is done by overloading put to call
90 JAWS_Thread_Per_Task (long flags
= THR_NEW_LWP
, int maxthreads
= 20);
92 virtual int put (ACE_Message_Block
*mb
, ACE_Time_Value
*tv
= 0);
99 #endif /* !defined (JAWS_CONCURRENCY_H) */