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 6657 2026-10-28 18:19:39Z wini $
15 *
16 * COPYRIGHT: Real Time Logic LLC, 2002-2026
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 <BaSocketConfig.h>
46#include <ThreadLib.h>
47
48
49struct SoDispCon;
50struct HttpServer;
51
96typedef struct SoDisp
97{
98#ifdef __cplusplus
99
100 void *operator new(size_t s) { return ::baMalloc(s); }
101 void operator delete(void* d) { if(d) ::baFree(d); }
102 void *operator new(size_t, void *place) { return place; }
103 void operator delete(void*, void *) { }
104
110 SoDisp(ThreadMutex* mutex);
111
117 void mutexSet();
118
123 void mutexRelease();
124
129
133 void addConnection(SoDispCon* con);
137 void activateRec(SoDispCon* con);
140 void deactivateRec(SoDispCon* con);
144 void activateSend(SoDispCon* con);
148 void deactivateSend(SoDispCon* con);
152 void removeConnection(SoDispCon* con);
153
159 void setExit();
160
173 void run(S32 timeout=-1);
174#endif
175 DISPATCHER_DATA;
176 ThreadMutex* mutex;
177 void* timeoutO;
178 BaBool doExit;
180
181#ifdef __cplusplus
182extern "C" {
183#endif
186BA_API void SoDisp_constructor(SoDisp* o, ThreadMutex* mutex);
187#ifndef SoDisp_destructor
188#define SoDisp_destructor(o)
189#endif
192BA_API void SoDisp_addConnection(SoDisp* o, struct SoDispCon* con);
195BA_API void SoDisp_activateRec(SoDisp* o, struct SoDispCon* con);
198BA_API void SoDisp_deactivateRec(SoDisp* o, struct SoDispCon* con);
199#if !BA_HAVE_SOCKET_WRITE_EVENTS
200#define SoDisp_activateSend(o, con)
201#define SoDisp_deactivateSend(o, con)
202#else
205BA_API void SoDisp_activateSend(SoDisp* o, struct SoDispCon* con);
208BA_API void SoDisp_deactivateSend(SoDisp* o, struct SoDispCon* con);
209#endif
212BA_API void SoDisp_removeConnection(SoDisp* o, struct SoDispCon* con);
215BA_API void SoDisp_run(SoDisp* o, S32 timeout);
216#ifdef OSE
217union SIGNAL* SoDisp_receive(SoDisp* o, S32 time, SIGSELECT* sel);
218#endif
221#define SoDisp_getMutex(o) ((o) ? ((o)->mutex) : 0)
224#define SoDisp_mutexSet(o) ThreadMutex_set((o)->mutex)
227#define SoDisp_mutexRelease(o) ThreadMutex_release((o)->mutex)
230#define SoDisp_setExit(o) (o)->doExit=TRUE
231
232BA_API void SoDisp_newCon(SoDisp*, struct SoDispCon*);
233
234#ifdef __cplusplus
235}
237 SoDisp_constructor(this, mutex); }
239 SoDisp_addConnection(this, con); }
241 SoDisp_activateRec(this, con); }
243 SoDisp_deactivateRec(this, con); }
245 SoDisp_activateSend(this, con); }
247 SoDisp_deactivateSend(this, con); }
249 SoDisp_removeConnection(this, con); }
250inline void SoDisp::run(S32 timeout) {
251 SoDisp_run(this, timeout); }
253 return this->mutex; }
254#ifdef OSE
255inline union SIGNAL* SoDisp::receive(S32 time, SIGSELECT* sel) {
256 return SoDisp_receive(this, time, sel); }
257#endif
258inline void SoDisp::mutexSet() { SoDisp_mutexSet(this); }
260inline void SoDisp::setExit() { SoDisp_setExit(this); }
261
262#endif
263
264void SoDisp_setTimeout(
265 SoDisp* o, BaTime t, void (*cb)(void* object), void* object);
266
267
268#endif
BA_API void SoDisp_run(SoDisp *o, S32 timeout)
Run the generic socket dispatcher loop.
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:227
#define SoDisp_mutexSet(o)
Acquire the configured mutex; do not acquire recursively.
Definition: SoDisp.h:224
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...
#define SoDisp_setExit(o)
Definition: SoDisp.h:230
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:88
S64 BaTime
An arithmetic type representing calendar time with epoch of 1970-01-01 00:00:00 UTC,...
Definition: GenPrimT.h:106
U8 BaBool
Boolean stored in an unsigned byte; FALSE is zero and TRUE is one.
Definition: GenPrimT.h:121
Route and process HTTP requests using a borrowed dispatcher.
Definition: HttpServer.h:3464
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:97
void mutexRelease()
Release the mutex currently owned by this thread.
Definition: SoDisp.h:259
void run(S32 timeout=-1)
Run the generic socket dispatcher loop.
Definition: SoDisp.h:250
void activateRec(SoDispCon *con)
Enable receive events.
Definition: SoDisp.h:240
SoDisp(ThreadMutex *mutex)
The constructor.
Definition: SoDisp.h:236
void setExit()
Request that the current run loop exits after it regains control.
Definition: SoDisp.h:260
void activateSend(SoDispCon *con)
Enable send-ready events.
Definition: SoDisp.h:244
void addConnection(SoDispCon *con)
Register a connection without enabling events.
Definition: SoDisp.h:238
void mutexSet()
Lock the dispatcher thread.
Definition: SoDisp.h:258
void removeConnection(SoDispCon *con)
Unregister a connection without closing or freeing it.
Definition: SoDisp.h:248
ThreadMutex * getMutex()
Definition: SoDisp.h:252
void deactivateRec(SoDispCon *con)
Disable receive events without closing or unregistering the connection.
Definition: SoDisp.h:242
void deactivateSend(SoDispCon *con)
Disable send-ready events without closing or unregistering the connection.
Definition: SoDisp.h:246
A mutual exclusion class.
Definition: ThreadLib.h:196