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)
69 InitializeCriticalSection (&cs);
74 DeleteCriticalSection (&cs);
79 EnterCriticalSection (&cs);
84 LeaveCriticalSection (&cs);
89 return (TryEnterCriticalSection (&cs) != 0);
96static DWORD thread_id = 0;
101 thread_id = GetCurrentThreadId ();
107 return (GetCurrentThreadId () == thread_id);
110#elif defined (HAVE_PTHREAD_H)
119 pthread_mutexattr_t attr;
121 pthread_mutexattr_init (&attr);
122 pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE);
123 pthread_mutex_init (&m_pm, &attr);
124 pthread_mutexattr_destroy (&attr);
127 OCTAVE_DISABLE_COPY_MOVE (pthread_mutex)
131 pthread_mutex_destroy (&m_pm);
136 pthread_mutex_lock (&m_pm);
141 pthread_mutex_unlock (&m_pm);
146 return (pthread_mutex_trylock (&m_pm) == 0);
150 pthread_mutex_t m_pm;
153static pthread_t thread_id = 0;
158 thread_id = pthread_self ();
164 return (pthread_equal (thread_id, pthread_self ()) != 0);
172#if defined (OCTAVE_USE_WINDOWS_API)
173 return new w32_mutex ();
174#elif defined (HAVE_PTHREAD_H)
175 return new pthread_mutex ();
183OCTAVE_END_NAMESPACE(octave)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn