Mercurial > hg > octave-lyh
diff liboctave/oct-mutex.cc @ 7952:2c0a0edae596
reorganize octave_mutex class
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 19 Jul 2008 22:59:14 -0400 |
parents | 7b8aca1cdf0a |
children | ba2e00a216e8 |
line wrap: on
line diff
--- a/liboctave/oct-mutex.cc +++ b/liboctave/oct-mutex.cc @@ -35,85 +35,83 @@ #include <windows.h> #endif -class -octave_default_mutex : public octave_mutex +void +octave_base_mutex::lock (void) { -public: - octave_default_mutex (void) - : octave_mutex (-1) { } + error ("mutex not supported on this platform"); +} - void lock (void) - { error ("mutex not supported on this platform"); } - - void unlock(void) - { error ("mutex not supported on this platform"); } -}; +void +octave_base_mutex::unlock (void) +{ + error ("mutex not supported on this platform"); +} #if defined (__WIN32__) && ! defined (__CYGWIN__) class -octave_w32_mutex : public octave_mutex +octave_w32_mutex : public octave_base_mutex { public: - octave_w32_mutex (void) - : octave_mutex (-1) - { - InitializeCriticalSection (&cs); - } + octave_w32_mutex (void) + : octave_base_mutex () + { + InitializeCriticalSection (&cs); + } - ~octave_w32_mutex (void) - { - DeleteCriticalSection (&cs); - } + ~octave_w32_mutex (void) + { + DeleteCriticalSection (&cs); + } - void lock (void) - { - EnterCriticalSection (&cs); - } + void lock (void) + { + EnterCriticalSection (&cs); + } - void unlock (void) - { - LeaveCriticalSection (&cs); - } + void unlock (void) + { + LeaveCriticalSection (&cs); + } private: - CRITICAL_SECTION cs; + CRITICAL_SECTION cs; }; #elif defined (HAVE_PTHREAD_H) class -octave_pthread_mutex : public octave_mutex +octave_pthread_mutex : public octave_base_mutex { public: - octave_pthread_mutex (void) - : octave_mutex (-1) - { - pthread_mutexattr_t attr; + octave_pthread_mutex (void) + : octave_base_mutex () + { + pthread_mutexattr_t attr; - pthread_mutexattr_init (&attr); - pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init (&pm, &attr); - pthread_mutexattr_destroy (&attr); - } + pthread_mutexattr_init (&attr); + pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE); + pthread_mutex_init (&pm, &attr); + pthread_mutexattr_destroy (&attr); + } - ~octave_pthread_mutex (void) - { - pthread_mutex_destroy (&pm); - } + ~octave_pthread_mutex (void) + { + pthread_mutex_destroy (&pm); + } - void lock (void) - { - pthread_mutex_lock (&pm); - } + void lock (void) + { + pthread_mutex_lock (&pm); + } - void unlock (void) - { - pthread_mutex_unlock (&pm); - } + void unlock (void) + { + pthread_mutex_unlock (&pm); + } private: - pthread_mutex_t pm; + pthread_mutex_t pm; }; #endif @@ -125,7 +123,6 @@ #elif defined (HAVE_PTHREAD_H) rep = new octave_pthread_mutex (); #else - rep = new octave_default_mutex (); + rep = new octave_base_mutex (); #endif - rep->count = 1; }