10 #ifndef MUTEXLOCK_H_INCLUDED_IVILAB_2013AUG09
11 #define MUTEXLOCK_H_INCLUDED_IVILAB_2013AUG09
13 #include <l_mt/l_mt_pthread.h>
58 kjb_c::kjb_pthread_mutex_t mutex_;
65 void fp_abort(
const char*);
71 #ifndef KJB_HAVE_PTHREAD
74 ETX(kjb_c::kjb_pthread_mutex_init(&mutex_, 0));
85 if (kjb_c::ERROR == kjb_c::kjb_pthread_mutex_destroy(&mutex_))
94 ETX(kjb_c::kjb_pthread_mutex_lock(&mutex_));
100 ETX(kjb_c::kjb_pthread_mutex_unlock(&mutex_));
106 return kjb_c::kjb_pthread_mutex_trylock(&mutex_);
135 kjb_c::kjb_pthread_mutex_t* mutex_;
142 ETX(kjb_c::kjb_pthread_mutex_lock(mutex_));
145 void fp_abort(
const char*);
164 : mutex_(m ? & m -> mutex_ : 0)
174 if (kjb_c::ERROR == kjb_c::kjb_pthread_mutex_unlock(mutex_))
#define ETX(a)
Definition: l_exception.h:67
void lock()
lock this mutex
Definition: l_mt_mutexlock.h:92
Mutex_lock(Pthread_mutex *m)
establish a lock on the mutex object pointer
Definition: l_mt_mutexlock.h:163
Mutex_lock(kjb_c::kjb_pthread_mutex_t *m)
establish a lock on the mutex (as a C-style struct)
Definition: l_mt_mutexlock.h:149
Mutex_lock(Pthread_mutex &m)
establish a lock on the mutex object (as a reference)
Definition: l_mt_mutexlock.h:156
Pthread_locked_mutex()
Definition: l_mt_mutexlock.h:114
#define NTX(a)
Definition: l_exception.h:89
~Mutex_lock()
dtor releases the mutex
Definition: l_mt_mutexlock.h:183
simple RAII class to grab and release a mutex
Definition: l_mt_mutexlock.h:133
int try_lock()
try to lock; return WOULD_BLOCK if locked, else NO_ERROR.
Definition: l_mt_mutexlock.h:104
void release()
release the mutex for others (safe to call twice)
Definition: l_mt_mutexlock.h:170
#define KJB_THROW_2(ex, msg)
Definition: l_exception.h:48
virtual ~Pthread_mutex()
dtor cleans up the mutex, which MUST be unlocked beforehand.
Definition: l_mt_mutexlock.h:83
Pthread_mutex(void(Pthread_mutex::*pmf)()=0)
dynamic mutex: unlock before you destroy it!
Definition: l_mt_mutexlock.h:69
same as Pthread_mutex, but starts off in "locked" state.
Definition: l_mt_mutexlock.h:112
for m
Definition: APPgetLargeConnectedEdges.m:64
Support for error handling exception classes in libKJB.
Object thrown when a program lacks required resources or libraries.
Definition: l_exception.h:539
dynamically allocated mutex: unlock before you destroy it!
Definition: l_mt_mutexlock.h:56
void unlock()
unlock this mutex
Definition: l_mt_mutexlock.h:98
std::string kjb_get_error()
similar to kjb_c::kjb_get_error(), but this returns std::string.
Definition: l_exception.cpp:723