Barracuda Application Server C/C++ Reference
NO
SoDisp.h
1 /*
2  * ____ _________ __ _
3  * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____
4  * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/
5  * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__
6  * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/
7  * /____/
8  *
9  * Barracuda Embedded Web-Server
10  *
11  ****************************************************************************
12  * HEADER
13  *
14  * $Id: SoDisp.h 5078 2022-02-10 22:52:48Z wini $
15  *
16  * COPYRIGHT: Real Time Logic LLC, 2002-2021
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 #endif
142  DISPATCHER_DATA;
143  ThreadMutex* mutex;
144  void* timeoutO;
145  BaBool doExit;
146 } SoDisp;
147 
148 #ifdef __cplusplus
149 extern "C" {
150 #endif
151 BA_API void SoDisp_constructor(SoDisp* o, ThreadMutex* mutex);
152 #ifndef SoDisp_destructor
153 #define SoDisp_destructor(o)
154 #endif
155 BA_API void SoDisp_addConnection(SoDisp* o, struct SoDispCon* con);
156 BA_API void SoDisp_activateRec(SoDisp* o, struct SoDispCon* con);
157 BA_API void SoDisp_deactivateRec(SoDisp* o, struct SoDispCon* con);
158 #ifdef NO_ASYNCH_RESP
159 #define SoDisp_activateSend(o, con)
160 #define SoDisp_deactivateSend(o, con)
161 #else
162 BA_API void SoDisp_activateSend(SoDisp* o, struct SoDispCon* con);
163 BA_API void SoDisp_deactivateSend(SoDisp* o, struct SoDispCon* con);
164 #endif
165 BA_API void SoDisp_removeConnection(SoDisp* o, struct SoDispCon* con);
166 BA_API void SoDisp_run(SoDisp* o, S32 timeout);
167 #ifdef OSE
168 union SIGNAL* SoDisp_receive(SoDisp* o, S32 time, SIGSELECT* sel);
169 #endif
170 #define SoDisp_getMutex(o) ((o) ? ((o)->mutex) : 0)
171 #define SoDisp_mutexSet(o) ThreadMutex_set((o)->mutex)
172 #define SoDisp_mutexRelease(o) ThreadMutex_release((o)->mutex)
173 #define SoDisp_setExit(o) (o)->doExit=TRUE
174 
175 BA_API void SoDisp_newCon(SoDisp*, struct SoDispCon*);
176 
177 #ifdef __cplusplus
178 }
179 inline SoDisp::SoDisp(ThreadMutex* mutex) {
180  SoDisp_constructor(this, mutex); }
181 inline void SoDisp::addConnection(SoDispCon* con) {
182  SoDisp_addConnection(this, con); }
183 inline void SoDisp::activateRec(SoDispCon* con) {
184  SoDisp_activateRec(this, con); }
185 inline void SoDisp::deactivateRec(SoDispCon* con) {
186  SoDisp_deactivateRec(this, con); }
187 inline void SoDisp::activateSend(SoDispCon* con) {
188  SoDisp_activateSend(this, con); }
189 inline void SoDisp::deactivateSend(SoDispCon* con) {
190  SoDisp_deactivateSend(this, con); }
191 inline void SoDisp::removeConnection(SoDispCon* con) {
192  SoDisp_removeConnection(this, con); }
193 inline void SoDisp::run(S32 timeout) {
194  SoDisp_run(this, timeout); }
196  return this->mutex; }
197 #ifdef OSE
198 inline union SIGNAL* SoDisp::receive(S32 time, SIGSELECT* sel) {
199  return SoDisp_receive(this, time, sel); }
200 #endif
201 inline void SoDisp::mutexSet() { SoDisp_mutexSet(this); }
202 inline void SoDisp::mutexRelease() {SoDisp_mutexRelease(this);}
203 inline void SoDisp::setExit() { SoDisp_setExit(this); }
204 
205 #endif
206 
207 void SoDisp_setTimeout(
208  SoDisp* o, BaTime t, void (*cb)(void* object), void* object);
209 
210 
211 #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:93
baFree
void baFree(void *p)
Deallocates space to which it points.
SoDisp::SoDisp
SoDisp(ThreadMutex *mutex)
The constructor.
Definition: SoDisp.h:179
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:195
SoDisp::mutexSet
void mutexSet()
Lock the dispatcher thread.
Definition: SoDisp.h:201
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:202
SoDisp::run
void run(S32 timeout=-1)
Call the socket dispatcher loop, which dispatches HTTP requests.
Definition: SoDisp.h:193
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:203