24 #ifndef LOG4CPLUS_THREAD_SYNCPRIMS_H
25 #define LOG4CPLUS_THREAD_SYNCPRIMS_H
28 #include "dcmtk/oflog/config.h"
29 #if defined (LOG4CPLUS_USE_PTHREADS)
30 # define INCLUDE_CERRNO
31 # include "dcmtk/ofstd/ofstdinc.h"
34 # include <semaphore.h>
37 #elif defined (LOG4CPLUS_USE_WIN32_THREADS)
38 # undef WIN32_LEAN_AND_MEAN
39 # define WIN32_LEAN_AND_MEAN
45 namespace log4cplus {
namespace thread {
51 LOG4CPLUS_EXPORT
void syncprims_throw_exception (
char const *
const msg,
52 char const *
const file,
int line);
57 template <
typename SP>
66 void attach (SP
const &);
90 #if defined (LOG4CPLUS_USE_PTHREADS)
91 mutable pthread_mutex_t mtx;
93 #elif defined (LOG4CPLUS_USE_WIN32_THREADS)
94 mutable CRITICAL_SECTION cs;
108 Semaphore (
unsigned max,
unsigned initial);
112 void unlock ()
const;
115 #if defined (LOG4CPLUS_USE_PTHREADS)
117 #elif defined (LOG4CPLUS_USE_WIN32_THREADS)
135 void signal ()
const;
137 bool timed_wait (
unsigned long msec)
const;
141 #if defined (LOG4CPLUS_USE_PTHREADS)
142 mutable pthread_cond_t cv;
144 mutable volatile unsigned sigcount;
145 mutable volatile bool signaled;
146 #elif defined (LOG4CPLUS_USE_WIN32_THREADS)
161 #if defined (LOG4CPLUS_USE_PTHREADS)
163 #elif defined (LOG4CPLUS_USE_WIN32_THREADS)
168 namespace log4cplus {
namespace thread {
175 template <
typename SP>
177 SyncGuard<SP>::SyncGuard (SP
const & m)
184 template <
typename SP>
186 SyncGuard<SP>::~SyncGuard ()
193 template <
typename SP>
196 SyncGuard<SP>::lock ()
202 template <
typename SP>
205 SyncGuard<SP>::unlock ()
211 template <
typename SP>
214 SyncGuard<SP>::attach (SP
const & m)
220 template <
typename SP>
223 SyncGuard<SP>::detach ()
233 #endif // LOG4CPLUS_THREAD_SYNCPRIMS_H