Barracuda Application Server C/C++ Reference
Native APIs, integration guides, and platform interfaces
SoDisp.h
Go to the documentation of this file.
1/*
2 * ____ _________ __ _
3 * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____
4 * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/
5 * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__
6 * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/
7 * /____/
8 *
9 * Barracuda Embedded Web-Server
10 *
11 ****************************************************************************
12 * HEADER
13 *
14 * $Id: SoDisp.h 5978 2026-09-11 16:13: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
41#ifndef _SoDisp_h
42#define _SoDisp_h
43
44#include <HttpCfg.h>
45#include <ThreadLib.h>
46
47
48struct SoDispCon;
49struct HttpServer;
50
90typedef struct SoDisp
91{
92#ifdef __cplusplus
93
94 void *operator new(size_t s) { return ::baMalloc(s); }
95 void operator delete(void* d) { if(d) ::baFree(d); }
96 void *operator new(size_t, void *place) { return place; }
97 void operator delete(void*, void *) { }
98
104 SoDisp(ThreadMutex* mutex);
105
111 void mutexSet();
112
117 void mutexRelease();
118
123
127 void addConnection(SoDispCon* con);
131 void activateRec(SoDispCon* con);
134 void deactivateRec(SoDispCon* con);
138 void activateSend(SoDispCon* con);
142 void deactivateSend(SoDispCon* con);
146 void removeConnection(SoDispCon* con);
147
153 void setExit();
154
167 void run(S32 timeout=-1);
168#endif
169 DISPATCHER_DATA;
170 ThreadMutex* mutex;
171 void* timeoutO;
172 BaBool doExit;
174
175#ifdef __cplusplus
176extern "C" {
177#endif
180BA_API void SoDisp_constructor(SoDisp* o, ThreadMutex* mutex);
181#ifndef SoDisp_destructor
182#define SoDisp_destructor(o)
183#endif
186BA_API void SoDisp_addConnection(SoDisp* o, struct SoDispCon* con);
189BA_API void SoDisp_activateRec(SoDisp* o, struct SoDispCon* con);
192BA_API void SoDisp_deactivateRec(SoDisp* o, struct SoDispCon* con);
193#ifdef NO_ASYNCH_RESP
194#define SoDisp_activateSend(o, con)
195#define SoDisp_deactivateSend(o, con)
196#else
199BA_API void SoDisp_activateSend(SoDisp* o, struct SoDispCon* con);
202BA_API void SoDisp_deactivateSend(SoDisp* o, struct SoDispCon* con);
203#endif
206BA_API void SoDisp_removeConnection(SoDisp* o, struct SoDispCon* con);
209BA_API void SoDisp_run(SoDisp* o, S32 timeout);
210#ifdef OSE
211union SIGNAL* SoDisp_receive(SoDisp* o, S32 time, SIGSELECT* sel);
212#endif
215#define SoDisp_getMutex(o) ((o) ? ((o)->mutex) : 0)
218#define SoDisp_mutexSet(o) ThreadMutex_set((o)->mutex)
221#define SoDisp_mutexRelease(o) ThreadMutex_release((o)->mutex)
224#define SoDisp_setExit(o) (o)->doExit=TRUE
225
226BA_API void SoDisp_newCon(SoDisp*, struct SoDispCon*);
227
228#ifdef __cplusplus
229}
231 SoDisp_constructor(this, mutex); }
233 SoDisp_addConnection(this, con); }
235 SoDisp_activateRec(this, con); }
237 SoDisp_deactivateRec(this, con); }
239 SoDisp_activateSend(this, con); }
241 SoDisp_deactivateSend(this, con); }
243 SoDisp_removeConnection(this, con); }
244inline void SoDisp::run(S32 timeout) {
245 SoDisp_run(this, timeout); }
247 return this->mutex; }
248#ifdef OSE
249inline union SIGNAL* SoDisp::receive(S32 time, SIGSELECT* sel) {
250 return SoDisp_receive(this, time, sel); }
251#endif
252inline void SoDisp::mutexSet() { SoDisp_mutexSet(this); }
254inline void SoDisp::setExit() { SoDisp_setExit(this); }
255
256#endif
257
258void SoDisp_setTimeout(
259 SoDisp* o, BaTime t, void (*cb)(void* object), void* object);
260
261
262#endif
BA_API void SoDisp_run(SoDisp *o, S32 timeout)
Run the generic socket dispatcher loop.
BA_API void SoDisp_activateSend(SoDisp *o, struct SoDispCon *con)
Enable send-ready events.
BA_API void SoDisp_activateRec(SoDisp *o, struct SoDispCon *con)
Enable receive events.
#define SoDisp_mutexRelease(o)
Release the configured mutex owned by this thread.
Definition: SoDisp.h:221
#define SoDisp_mutexSet(o)
Acquire the configured mutex; do not acquire recursively.
Definition: SoDisp.h:218
BA_API void SoDisp_constructor(SoDisp *o, ThreadMutex *mutex)
The constructor.
BA_API void SoDisp_removeConnection(SoDisp *o, struct SoDispCon *con)
Unregister a connection without closing or freeing it.
BA_API void SoDisp_deactivateRec(SoDisp *o, struct SoDispCon *con)
Disable receive events without closing or unregistering the connection.
struct SoDisp SoDisp
The SoDisp dispatches any socket connection that contains data by calling the SoDispCon::execute memb...
BA_API void SoDisp_deactivateSend(SoDisp *o, struct SoDispCon *con)
Disable send-ready events without closing or unregistering the connection.
#define SoDisp_setExit(o)
Definition: SoDisp.h:224
BA_API void SoDisp_addConnection(SoDisp *o, struct SoDispCon *con)
Register a connection without enabling events.
void * baMalloc(size_t size)
Allocate uninitialized storage using the target's configured allocator.
void baFree(void *p)
Release storage using the target's configured allocator.
int32_t S32
Signed 32-bit integer.
Definition: GenPrimT.h:85
S64 BaTime
An arithmetic type representing calendar time with epoch of 1970-01-01 00:00:00 UTC,...
Definition: GenPrimT.h:103
U8 BaBool
Boolean stored in an unsigned byte; FALSE is zero and TRUE is one.
Definition: GenPrimT.h:118
The Web Server.
Definition: HttpServer.h:3393
Contains information about the physical socket connection.
Definition: SoDispCon.h:120
The SoDisp dispatches any socket connection that contains data by calling the SoDispCon::execute memb...
Definition: SoDisp.h:91
void mutexRelease()
Release the mutex currently owned by this thread.
Definition: SoDisp.h:253
void run(S32 timeout=-1)
Run the generic socket dispatcher loop.
Definition: SoDisp.h:244
void activateRec(SoDispCon *con)
Enable receive events.
Definition: SoDisp.h:234
SoDisp(ThreadMutex *mutex)
The constructor.
Definition: SoDisp.h:230
void setExit()
Request that the current run loop exits after it regains control.
Definition: SoDisp.h:254
void activateSend(SoDispCon *con)
Enable send-ready events.
Definition: SoDisp.h:238
void addConnection(SoDispCon *con)
Register a connection without enabling events.
Definition: SoDisp.h:232
void mutexSet()
Lock the dispatcher thread.
Definition: SoDisp.h:252
void removeConnection(SoDispCon *con)
Unregister a connection without closing or freeing it.
Definition: SoDisp.h:242
ThreadMutex * getMutex()
Definition: SoDisp.h:246
void deactivateRec(SoDispCon *con)
Disable receive events without closing or unregistering the connection.
Definition: SoDisp.h:236
void deactivateSend(SoDispCon *con)
Disable send-ready events without closing or unregistering the connection.
Definition: SoDisp.h:240
A mutual exclusion class.
Definition: ThreadLib.h:196