54 #ifndef _SAG_CONNECTIVITY_THREADS_HPP_    55 #define _SAG_CONNECTIVITY_THREADS_HPP_    57 #if defined(_WIN32) || defined(__WIN32) || defined(WIN32)    68 #define SAG_MUTEX_LOCK(m) EnterCriticalSection(&m)    70 #define SAG_MUTEX_UNLOCK(m) LeaveCriticalSection(&m)    72 #define SAG_MUTEX_INIT(m) InitializeCriticalSection(&m)    74 #define SAG_MUTEX_DESTROY(m) DeleteCriticalSection(&m)    80 #define SAG_MUTEX_T CRITICAL_SECTION    83 #define SAG_SEMA_WAIT(s) WaitForSingleObject(s, INFINITE)    85 #define SAG_SEMA_POST(s) ReleaseSemaphore(s, 1, NULL)    87 #define SAG_SEMA_INIT(s) s = CreateSemaphore(NULL, 0, 0x7FFFFFFF, NULL)    89 #define SAG_SEMA_DESTROY(s) CloseHandle(s)    96 #define SAG_SEMA_T HANDLE   103 #define SAG_THREAD_CREATE(id, func, params) (!(id = (HANDLE)_beginthreadex(NULL, 0, func, params, 0, NULL)))   105 #define SAG_THREAD_JOIN(id) WaitForSingleObject(id, INFINITE)   107 #define SAG_THREAD_RETURN return 0;   109 #define SAG_THREAD_T HANDLE    111 #define SAG_THREAD_RET_T unsigned int __stdcall    113 #else // defined(_WIN32) || defined(__WIN32) || defined(WIN32)   118 #include <semaphore.h>   124 #define SAG_MUTEX_LOCK(m) pthread_mutex_lock(&m)   126 #define SAG_MUTEX_UNLOCK(m) pthread_mutex_unlock(&m)   128 #define SAG_MUTEX_INIT(m) pthread_mutex_init(&m, NULL)   130 #define SAG_MUTEX_DESTROY(m) pthread_mutex_destroy(&m)   137 #define SAG_MUTEX_T pthread_mutex_t   140 #define SAG_SEMA_WAIT(s) {while (sem_wait(&s));}   142 #define SAG_SEMA_POST(s) sem_post(&s)   144 #define SAG_SEMA_INIT(s) sem_init(&s, 0, 0)   146 #define SAG_SEMA_DESTROY(s) sem_destroy(&s)   153 #define SAG_SEMA_T sem_t   160 #define SAG_THREAD_CREATE(id, func, params) pthread_create(& id, NULL, func, params)   162 #define SAG_THREAD_JOIN(id) pthread_join(id, NULL)   164 #define SAG_THREAD_RETURN return NULL;   166 #define SAG_THREAD_T pthread_t   168 #define SAG_THREAD_RET_T void*   171 #endif // (else) defined(_WIN32) || defined(__WIN32) || defined(WIN32)   178 namespace softwareag {
   179 namespace _DATAT_INTERNAL_CPP_NAMESPACE {
   198                 :mx(mx), locked(false)
   213                 if (locked) 
throw std::runtime_error(
"Cannot lock a SAG_MUTEX_T that is already locked");
   220                 if (!locked) 
throw std::runtime_error(
"Cannot unlock a SAG_MUTEX_T that is already unlocked");
   241 namespace connectivity { 
using namespace _DATAT_INTERNAL_CPP_NAMESPACE; }
   244 #endif // __cplusplus   246 #endif // _SAG_CONNECTIVITY_THREADS_HPP_ #define SAG_MUTEX_LOCK(m)
Lock a mutex.
Definition: sag_connectivity_threading.h:124
SAG_LOCK_GUARD(SAG_MUTEX_T &mx)
Create a SAG_LOG_GUARD for a particular mutex.
Definition: sag_connectivity_threading.h:197
A simple RAII wrapper for SAG_MUTEX_T that locks the specified mutex in its constructor,...
Definition: sag_connectivity_threading.h:193
void lock()
Locks the mutex (throws if the mutex is already locked by this lock guard).
Definition: sag_connectivity_threading.h:211
#define SAG_MUTEX_T
A helper that provides cross-platform mutex functionality for use on old compilers.
Definition: sag_connectivity_threading.h:137
void unlock()
Unlocks the mutex (throws if the mutex is already unlocked by this lock guard).
Definition: sag_connectivity_threading.h:218
~SAG_LOCK_GUARD()
Destroy this lock guard.
Definition: sag_connectivity_threading.h:204
#define SAG_MUTEX_UNLOCK(m)
Unlock a mutex.
Definition: sag_connectivity_threading.h:126