23 #if defined (HAVE_CONFIG_H) 30 #if defined (OCTAVE_USE_WINDOWS_API) 32 #elif defined (HAVE_PTHREAD_H) 41 (*current_liboctave_error_handler) (
"mutex not supported on this platform");
47 (*current_liboctave_error_handler) (
"mutex not supported on this platform");
53 (*current_liboctave_error_handler) (
"mutex not supported on this platform");
58 #if defined (OCTAVE_USE_WINDOWS_API) 67 InitializeCriticalSection (&
cs);
72 DeleteCriticalSection (&
cs);
77 EnterCriticalSection (&
cs);
82 LeaveCriticalSection (&
cs);
87 return (TryEnterCriticalSection (&
cs) != 0);
94 static DWORD thread_id = 0;
99 thread_id = GetCurrentThreadId ();
105 return (GetCurrentThreadId () == thread_id);
108 #elif defined (HAVE_PTHREAD_H) 111 pthread_mutex :
public base_mutex
115 : base_mutex (), pm ()
117 pthread_mutexattr_t attr;
119 pthread_mutexattr_init (&attr);
120 pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE);
121 pthread_mutex_init (&pm, &attr);
122 pthread_mutexattr_destroy (&attr);
125 ~pthread_mutex (
void)
127 pthread_mutex_destroy (&pm);
132 pthread_mutex_lock (&pm);
137 pthread_mutex_unlock (&pm);
142 return (pthread_mutex_trylock (&pm) == 0);
149 static pthread_t thread_id = 0;
154 thread_id = pthread_self ();
160 return (pthread_equal (thread_id, pthread_self ()) != 0);
168 #if defined (OCTAVE_USE_WINDOWS_API) 169 return new w32_mutex ();
170 #elif defined (HAVE_PTHREAD_H) 171 return new pthread_mutex ();
virtual void unlock(void)
virtual bool try_lock(void)
static base_mutex * init_rep(void)
static bool is_thread(void)