40#include <TargConfig.h>
83BA_API
void ThreadReleaseLock_internalConstructor(
93#if defined(__cplusplus)
171#define ThreadMutexBase ThreadMutex
172#define ThreadSemaphoreBase ThreadSemaphore
173#define ThreadBase Thread
177#include "ThreadLibArch.h"
179#if defined(__cplusplus)
188 void operator delete(
void* d) {
if(d)
::baFree(d); }
189 void *
operator new(size_t,
void *place) {
return place; }
190 void operator delete(
void*,
void *) { }
197 void set() { ThreadMutex_set(
this); }
203 bool isOwner() {
return ThreadMutex_isOwner(
this)?
true:
false; }
215 void operator delete(
void* d) {
if(d)
::baFree(d); }
216 void *
operator new(size_t,
void *place) {
return place; }
217 void operator delete(
void*,
void *) { }
228 void wait() { ThreadSemaphore_wait(
this); }
232 void signal() { ThreadSemaphore_signal(
this); }
244 void operator delete(
void* d) {
if(d)
::baFree(d); }
245 void *
operator new(size_t,
void *place) {
return place; }
246 void operator delete(
void*,
void *) { }
254 Thread_constructor(
this, r, priority, stackSize); }
255 ~Thread() { Thread_destructor(
this); }
258 void start() { Thread_start(
this); }
262 static void sleep(
unsigned int milliseconds) {
263 Thread_sleep(milliseconds); }
271 ThreadReleaseLock_internalConstructor(
this, req);
274 mutex(&m) { mutex->
release(); }
278 mutex(tl.mutex) { mutex->
release(); }
280 mutex(tl->mutex) { mutex->
release(); }
void * baMalloc(size_t size)
Returns pointer to uninitialized newly-allocated space for an object of size "size",...
void baFree(void *p)
Deallocates space to which it points.
ThreadLock(ThreadMutex &m)
Lock a region of code.
Definition: ThreadLib.h:266
~ThreadLock()
Unlock the mutex.
Definition: ThreadLib.h:268
ThreadPriority
Thread priority list.
Definition: ThreadLib.h:58
~ThreadReleaseLock()
Lock the temporarily unlock mutex.
Definition: ThreadLib.h:281
void(* Thread_Run)(struct Thread *th)
Prototype for the thread run method.
Definition: ThreadLib.h:75
ThreadReleaseLock(struct HttpRequest *req)
Temporarily unlock a locked mutex from within a resource.
Definition: ThreadLib.h:270
The HttpServer creates an HttpRequest object when the HttpServer parses a client request.
Definition: HttpServer.h:808
This class provides an easy and less error prone way of locking and releasing a mutex.
Definition: ThreadLib.h:116
A mutual exclusion class.
Definition: ThreadLib.h:186
void release()
Release the mutex.
Definition: ThreadLib.h:199
ThreadMutex()
Create a mutex.
Definition: ThreadLib.h:193
~ThreadMutex()
Destroy a mutex.
Definition: ThreadLib.h:195
void set()
Lock the mutex.
Definition: ThreadLib.h:197
bool isOwner()
Returns true if the mutex is locked and the current thread is the owner.
Definition: ThreadLib.h:203
This class provides an easy and less error prone way of temporarily releasing a locked mutex.
Definition: ThreadLib.h:152
A simple semaphore implementation.
Definition: ThreadLib.h:213
void wait()
Wait (block) for another thread to signal (start) the thread.
Definition: ThreadLib.h:228
~ThreadSemaphore(void)
destroy the semaphore
Definition: ThreadLib.h:224
ThreadSemaphore()
Create a semaphore and set the counter to zero.
Definition: ThreadLib.h:221
void signal()
Signal a waiting (blocking) thread.
Definition: ThreadLib.h:232
A simple thread class.
Definition: ThreadLib.h:241
void start()
Start the thread.
Definition: ThreadLib.h:258
Thread(Thread_Run r, ThreadPriority priority, int stackSize)
Create a thread.
Definition: ThreadLib.h:253
static void sleep(unsigned int milliseconds)
Suspend the current thread for n milliseconds.
Definition: ThreadLib.h:262