Barracuda Application Server C/C++ Reference
SoDisp.h
1 /*
2  * ____ _________ __ _
3  * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____
4  * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/
5  * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__
6  * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/
7  * /____/
8  *
9  * Barracuda Embedded Web-Server
10  *
11  ****************************************************************************
12  * HEADER
13  *
14  * $Id: SoDisp.h 4310 2018-05-30 20:54:41Z wini $
15  *
16  * COPYRIGHT: Real Time Logic LLC, 2002-2017
17  *
18  * This software is copyrighted by and is the sole property of Real
19  * Time Logic LLC. All rights, title, ownership, or other interests in
20  * the software remain the property of Real Time Logic LLC. This
21  * software may only be used in accordance with the terms and
22  * conditions stipulated in the corresponding license agreement under
23  * which the software has been supplied. Any unauthorized use,
24  * duplication, transmission, distribution, or disclosure of this
25  * software is expressly forbidden.
26  *
27  * This Copyright notice may not be removed or modified without prior
28  * written consent of Real Time Logic LLC.
29  *
30  * Real Time Logic LLC. reserves the right to modify this software
31  * without notice.
32  *
33  * http://www.realtimelogic.com
34  ****************************************************************************
35  *
36  *
37  */
38 
39 #ifndef _SoDisp_h
40 #define _SoDisp_h
41 
42 #include <HttpCfg.h>
43 #include <ThreadLib.h>
44 
45 
46 struct SoDispCon;
47 struct HttpServer;
48 
85 typedef struct SoDisp
86 {
87 #ifdef __cplusplus
88 
89  void *operator new(size_t s) { return ::baMalloc(s); }
90  void operator delete(void* d) { if(d) ::baFree(d); }
91  void *operator new(size_t, void *place) { return place; }
92  void operator delete(void*, void *) { }
93 
97  SoDisp(ThreadMutex* mutex);
98 
104  void mutexSet();
105 
109  void mutexRelease();
110 
114 
115  void addConnection(SoDispCon* con);
116  void activateRec(SoDispCon* con);
117  void deactivateRec(SoDispCon* con);
118  void activateSend(SoDispCon* con);
119  void deactivateSend(SoDispCon* con);
120  void removeConnection(SoDispCon* con);
121 
124  void setExit();
125 
140  void run(S32 timeout=-1);
141 #ifdef OSE
142  union SIGNAL* receive(S32 timeout=-1, SIGSELECT* sel=0);
143 #endif
144 #endif
145  DISPATCHER_DATA;
146  ThreadMutex* mutex;
147  void* timeoutO;
148  BaBool doExit;
149 } SoDisp;
150 
151 #ifdef __cplusplus
152 extern "C" {
153 #endif
154 BA_API void SoDisp_constructor(SoDisp* o, ThreadMutex* mutex);
155 #ifndef SoDisp_destructor
156 #define SoDisp_destructor(o)
157 #endif
158 BA_API void SoDisp_addConnection(SoDisp* o, struct SoDispCon* con);
159 BA_API void SoDisp_activateRec(SoDisp* o, struct SoDispCon* con);
160 BA_API void SoDisp_deactivateRec(SoDisp* o, struct SoDispCon* con);
161 #ifdef NO_ASYNCH_RESP
162 #define SoDisp_activateSend(o, con)
163 #define SoDisp_deactivateSend(o, con)
164 #else
165 BA_API void SoDisp_activateSend(SoDisp* o, struct SoDispCon* con);
166 BA_API void SoDisp_deactivateSend(SoDisp* o, struct SoDispCon* con);
167 #endif
168 BA_API void SoDisp_removeConnection(SoDisp* o, struct SoDispCon* con);
169 BA_API void SoDisp_run(SoDisp* o, S32 timeout);
170 #ifdef OSE
171 union SIGNAL* SoDisp_receive(SoDisp* o, S32 time, SIGSELECT* sel);
172 #endif
173 #define SoDisp_getMutex(o) ((o) ? ((o)->mutex) : 0)
174 #define SoDisp_mutexSet(o) ThreadMutex_set((o)->mutex)
175 #define SoDisp_mutexRelease(o) ThreadMutex_release((o)->mutex)
176 #define SoDisp_setExit(o) (o)->doExit=TRUE
177 
178 BA_API void SoDisp_newCon(SoDisp*, struct SoDispCon*);
179 
180 #ifdef __cplusplus
181 }
182 inline SoDisp::SoDisp(ThreadMutex* mutex) {
183  SoDisp_constructor(this, mutex); }
184 inline void SoDisp::addConnection(SoDispCon* con) {
185  SoDisp_addConnection(this, con); }
186 inline void SoDisp::activateRec(SoDispCon* con) {
187  SoDisp_activateRec(this, con); }
188 inline void SoDisp::deactivateRec(SoDispCon* con) {
189  SoDisp_deactivateRec(this, con); }
190 inline void SoDisp::activateSend(SoDispCon* con) {
191  SoDisp_activateSend(this, con); }
192 inline void SoDisp::deactivateSend(SoDispCon* con) {
193  SoDisp_deactivateSend(this, con); }
194 inline void SoDisp::removeConnection(SoDispCon* con) {
195  SoDisp_removeConnection(this, con); }
196 inline void SoDisp::run(S32 timeout) {
197  SoDisp_run(this, timeout); }
199  return SoDisp_getMutex(this); }
200 #ifdef OSE
201 inline union SIGNAL* SoDisp::receive(S32 time, SIGSELECT* sel) {
202  return SoDisp_receive(this, time, sel); }
203 #endif
204 inline void SoDisp::mutexSet() { SoDisp_mutexSet(this); }
205 inline void SoDisp::mutexRelease() {SoDisp_mutexRelease(this);}
206 inline void SoDisp::setExit() { SoDisp_setExit(this); }
207 
208 #endif
209 
210 void SoDisp_setTimeout(
211  SoDisp* o, BaTime t, void (*cb)(void* object), void* object);
212 
213 
214 #endif
SoDisp
The SoDisp dispatches any socket connection that contains data by calling the SoDispCon::execute memb...
Definition: SoDisp.h:86
BaTime
S64 BaTime
An arithmetic type representing calendar time with epoch of 1970-01-01 00:00:10 GMT – i....
Definition: GenPrimT.h:77
baFree
void baFree(void *p)
Deallocates space to which it points.
SoDisp::SoDisp
SoDisp(ThreadMutex *mutex)
The constructor.
Definition: SoDisp.h:182
baMalloc
void * baMalloc(size_t size)
Returns pointer to uninitialized newly-allocated space for an object of size "size",...
SoDisp::getMutex
ThreadMutex * getMutex()
Returns the SoDisp mutex.
Definition: SoDisp.h:198
SoDisp::mutexSet
void mutexSet()
Lock the dispatcher thread.
Definition: SoDisp.h:204
SoDispCon
Contains information about the physical socket connection.
Definition: SoDispCon.h:112
SoDisp::mutexRelease
void mutexRelease()
Releases the mutex if this is the last 'pop'.
Definition: SoDisp.h:205
SoDisp::run
void run(S32 timeout=-1)
Call the socket dispatcher loop, which dispatches HTTP requests.
Definition: SoDisp.h:196
ThreadMutex
A mutual exclusion class.
Definition: ThreadLib.h:186
HttpServer
The Web Server.
Definition: HttpServer.h:2887
SoDisp::setExit
void setExit()
The callbacks can force the dispatcher to exit the run method.
Definition: SoDisp.h:206