Annotation of parser3/src/main/pa_threads.C, revision 1.2

1.1       paf         1: /*
1.2     ! paf         2:   $Id: pa_threads.C,v 1.1 2001/01/29 11:17:50 paf Exp $
1.1       paf         3: */
                      4: 
                      5: #include "pa_threads.h"
                      6: 
                      7: #ifdef MULTITHREAD
                      8: 
1.2     ! paf         9: Mutex global_mutex;
        !            10: 
1.1       paf        11: // either apache module or win32 prog for now
                     12: #ifdef MOD_PARSER
                     13: #      include "ap_config.h"
                     14: #else// WIN32
                     15: #      include <winbase.h>
                     16: #endif
                     17: 
                     18: 
                     19: #ifdef MOD_PARSER
                     20: 
                     21: Mutex::Mutex() {
                     22:        handle=reinterpret_cast<mutex *>(ap_create_mutex(0));
                     23: }
                     24: 
                     25: Mutex::~Mutex() {
                     26:        ap_destroy_mutex(reinterpret_cast<mutex *>(handle));
                     27: }
                     28: 
1.2     ! paf        29: void Mutex::acquire() {
1.1       paf        30:        ap_acquire_mutex(reinterpret_cast<mutex *>(handle));
                     31: }
                     32: 
1.2     ! paf        33: void Mutex::release() {
1.1       paf        34:        ap_release_mutex(reinterpret_cast<mutex *>(handle));
                     35: }
                     36: 
                     37: #else// WIN32
                     38: 
                     39: Mutex::Mutex() {
                     40:        handle=CreateMutex(NULL, FALSE, 0);
                     41: }
                     42: 
                     43: Mutex::~Mutex() {
                     44:        CloseHandle(handle);
                     45: }
                     46: 
1.2     ! paf        47: void Mutex::acquire() {
1.1       paf        48:        WaitForSingleObject(handle, INFINITE);
                     49: }
                     50: 
1.2     ! paf        51: void Mutex::release() {
1.1       paf        52:        ReleaseMutex(handle);
                     53: }
                     54: 
                     55: #endif
                     56: 
                     57: #endif

E-mail: