Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / ACE / apps / JAWS / server / JAWS_Concurrency.h
blobc895bf1e8be7a4dbc36ca67d9ea26ecf1f870506
1 /* -*- c++ -*- */
2 #ifndef JAWS_CONCURRENCY_H
3 #define JAWS_CONCURRENCY_H
5 #include "ace/config-all.h"
7 #if !defined (ACE_LACKS_PRAGMA_ONCE)
8 # pragma once
9 #endif /* ACE_LACKS_PRAGMA_ONCE */
11 #include "ace/Task.h"
12 #include "JAWS_IO.h"
14 class JAWS_Concurrency_Base : public ACE_Task<ACE_SYNCH>
15 // = TITLE
16 // Base class for different concurrency models
18 // = DESCRIPTION
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().
24 public:
25 JAWS_Concurrency_Base ();
26 virtual int put (ACE_Message_Block *mb, ACE_Time_Value *tv = 0);
27 virtual int svc ();
30 class JAWS_Dispatch_Policy
31 // = TITLE
32 // Policy mechanism for choosing different concurrency models.
34 // = DESCRIPTION
35 // Given some (unspecified) state, decides what the concurrency
36 // model should be. (For now, we always return the same model.)
38 public:
39 JAWS_Dispatch_Policy ();
40 virtual ~JAWS_Dispatch_Policy ();
41 virtual JAWS_Concurrency_Base * update (void *state = 0) = 0;
44 class JAWS_Dispatcher
45 // = TITLE
46 // The class that is responsible to delivering events to the
47 // appropriate concurrency mechanism.
49 // = DESCRIPTION
50 // JAWS_IO_Handler calls into the dispatcher so that the completed
51 // IO can find a thread to take care of it.
53 public:
54 JAWS_Dispatcher (JAWS_Dispatch_Policy *policy);
56 int dispatch (JAWS_IO_Handler *ioh);
58 private:
59 JAWS_Dispatch_Policy *policy_;
62 class JAWS_Thread_Pool_Task : public JAWS_Concurrency_Base
63 // = TITLE
64 // Used to implement Thread Pool Concurrency Strategy
66 // = DESCRIPTION
67 // This task is created to hold a pool of threads that receive
68 // requests through the message queue.
70 public:
71 JAWS_Thread_Pool_Task (long flags = THR_NEW_LWP,
72 int nthreads = 5,
73 int maxthreads = 20);
75 private:
76 int nthreads_;
77 int maxthreads_;
80 class JAWS_Thread_Per_Task : public JAWS_Concurrency_Base
81 // = TITLE
82 // Used to implement Thread Per Request Concurrency Strategy
84 // = DESCRIPTION
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
87 // activate.
89 public:
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);
94 private:
95 long flags_;
96 int maxthreads_;
99 #endif /* !defined (JAWS_CONCURRENCY_H) */