3 //=============================================================================
9 //=============================================================================
15 #if !defined (ACE_LACKS_PRAGMA_ONCE)
17 #endif /* ACE_LACKS_PRAGMA_ONCE */
19 #include "ace/Service_Config.h"
20 #include "ace/Service_Object.h"
21 #include "ace/Thread_Manager.h"
22 #include "ace/Acceptor.h"
23 #include "ace/LOCK_SOCK_Acceptor.h"
24 #include "ace/Task_T.h"
25 #include "ace/Asynch_IO.h"
26 #include "ace/svc_export.h"
27 #include "HTTP_Handler.h"
28 #include "ace/Synch_Traits.h"
29 #include "ace/Thread_Mutex.h"
30 #include "ace/Null_Mutex.h"
31 #include "ace/Global_Macros.h"
33 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
34 // Forward declaration.
36 ACE_END_VERSIONED_NAMESPACE_DECL
38 #if defined (ACE_HAS_THREAD_SAFE_ACCEPT)
39 typedef ACE_LOCK_SOCK_Acceptor
<ACE_SYNCH_NULL_MUTEX
> HTTP_SOCK_Acceptor
;
41 typedef ACE_LOCK_SOCK_Acceptor
<ACE_SYNCH_MUTEX
> HTTP_SOCK_Acceptor
;
42 #endif /* ACE_HAS_THREAD_SAFE_ACCEPT */
44 typedef HTTP_SOCK_Acceptor HTTP_Acceptor
;
49 * @brief This server is used to create HTTP Handlers for the Web
52 class ACE_Svc_Export HTTP_Server
: public ACE_Service_Object
56 virtual int init (int argc
, ACE_TCHAR
*argv
[]);
62 /// Thread Per Request implementation
63 virtual int thread_per_request (HTTP_Handler_Factory
&factory
);
65 /// Asynch Thread Pool implementation
66 virtual int asynch_thread_pool ();
68 /// Synch Thread Pool implementation
69 virtual int synch_thread_pool (HTTP_Handler_Factory
&factory
);
72 // James, comment these data members.
73 void parse_args (int argc
, ACE_TCHAR
**argv
);
80 ACE_Thread_Manager tm_
;
81 HTTP_Acceptor acceptor_
;
85 * @class Synch_Thread_Pool_Task
87 * @brief Used to implement Synch Thread Pool
89 * Describe this and the others below.
90 * NOTE: this class was modified to make caching disabling possible
92 class Synch_Thread_Pool_Task
: public ACE_Task
<ACE_NULL_SYNCH
>
95 Synch_Thread_Pool_Task (HTTP_Acceptor
&acceptor
,
96 ACE_Thread_Manager
&tm
,
98 HTTP_Handler_Factory
&factory
);
102 HTTP_Acceptor
&acceptor_
;
103 HTTP_Handler_Factory
&factory_
;
107 * @class Thread_Per_Request_Task
109 * @brief Used to implement Thread Per Request.
111 * Spawns a new thread for every new incoming connection. The
112 * handle below is the socket stream of the incoming connection.
113 * NOTE: this class was modified to make caching disabling possible
115 class Thread_Per_Request_Task
: public ACE_Task
<ACE_NULL_SYNCH
>
118 Thread_Per_Request_Task (ACE_HANDLE handle
,
119 ACE_Thread_Manager
&tm
,
121 HTTP_Handler_Factory
&factory
);
122 virtual int open (void *args
= 0);
123 virtual int close (u_long
);
129 HTTP_Handler_Factory
&factory_
;
132 // This only works on Win32
133 #if defined (ACE_HAS_WIN32_OVERLAPPED_IO)
135 * @class Asynch_Thread_Pool_Task
137 * @brief Used to implement Asynch Thread Pool
139 * The proactor below utilizes WaitForMultipleObjects.
141 class Asynch_Thread_Pool_Task
: public ACE_Task
<ACE_NULL_SYNCH
>
144 Asynch_Thread_Pool_Task (ACE_Proactor
&proactor
,
145 ACE_Thread_Manager
&tm
);
149 ACE_Proactor
&proactor_
;
151 #endif /* ACE_HAS_WIN32_OVERLAPPED_IO */
153 ACE_SVC_FACTORY_DECLARE (HTTP_Server
)
155 ACE_STATIC_SVC_DECLARE_EXPORT (ACE_Svc
, HTTP_Server
)
157 #endif /* HTTP_SERVER_H */