26 #if defined (HAVE_CONFIG_H)
33 #if defined (OCTAVE_USE_WINDOWS_API)
35 #elif defined (HAVE_PTHREAD_H)
44 (*current_liboctave_error_handler) (
"mutex not supported on this platform");
50 (*current_liboctave_error_handler) (
"mutex not supported on this platform");
56 (*current_liboctave_error_handler) (
"mutex not supported on this platform");
61 #if defined (OCTAVE_USE_WINDOWS_API)
70 InitializeCriticalSection (&cs);
75 DeleteCriticalSection (&cs);
80 EnterCriticalSection (&cs);
85 LeaveCriticalSection (&cs);
90 return (TryEnterCriticalSection (&cs) != 0);
97 static DWORD thread_id = 0;
102 thread_id = GetCurrentThreadId ();
108 return (GetCurrentThreadId () == thread_id);
111 #elif defined (HAVE_PTHREAD_H)
121 pthread_mutexattr_t attr;
123 pthread_mutexattr_init (&attr);
124 pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE);
125 pthread_mutex_init (&m_pm, &attr);
126 pthread_mutexattr_destroy (&attr);
129 OCTAVE_DISABLE_COPY_MOVE (pthread_mutex)
133 pthread_mutex_destroy (&m_pm);
138 pthread_mutex_lock (&m_pm);
143 pthread_mutex_unlock (&m_pm);
148 return (pthread_mutex_trylock (&m_pm) == 0);
152 pthread_mutex_t m_pm;
155 static pthread_t thread_id = 0;
160 thread_id = pthread_self ();
166 return (pthread_equal (thread_id, pthread_self ()) != 0);
174 #if defined (OCTAVE_USE_WINDOWS_API)
175 return new w32_mutex ();
176 #elif defined (HAVE_PTHREAD_H)
177 return new pthread_mutex ();
185 OCTAVE_END_NAMESPACE(
octave)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn