19 #if !defined(__TBB_show_deprecation_message_mutex_H) && defined(__TBB_show_deprecated_header_message)
20 #define __TBB_show_deprecation_message_mutex_H
21 #pragma message("TBB Warning: tbb/mutex.h is deprecated. For details, please see Deprecated Features appendix in the TBB reference manual.")
24 #if defined(__TBB_show_deprecated_header_message)
25 #undef __TBB_show_deprecated_header_message
31 #define __TBB_mutex_H_include_area
53 #if TBB_USE_ASSERT || TBB_USE_THREADING_TOOLS
57 InitializeCriticalSectionEx(&impl, 4000, 0);
59 int error_code = pthread_mutex_init(&impl,NULL);
71 DeleteCriticalSection(&impl);
73 pthread_mutex_destroy(&impl);
80 friend class scoped_lock;
85 class scoped_lock : internal::no_copy {
88 scoped_lock() : my_mutex(NULL) {};
91 scoped_lock( mutex& mutex ) {
104 internal_acquire(mutex);
112 bool try_acquire( mutex& mutex ) {
114 return internal_try_acquire (mutex);
116 bool result = mutex.try_lock();
150 static const bool is_rw_mutex =
false;
151 static const bool is_recursive_mutex =
false;
152 static const bool is_fair_mutex =
false;
159 aligned_space<scoped_lock> tmp;
160 new(tmp.begin()) scoped_lock(*
this);
163 EnterCriticalSection(&impl);
165 int error_code = pthread_mutex_lock(&impl);
176 aligned_space<scoped_lock> tmp;
177 scoped_lock&
s = *tmp.begin();
179 return s.internal_try_acquire(*
this);
182 return TryEnterCriticalSection(&impl)!=0;
184 return pthread_mutex_trylock(&impl)==0;
192 aligned_space<scoped_lock> tmp;
193 scoped_lock&
s = *tmp.begin();
195 s.internal_release();
198 LeaveCriticalSection(&impl);
200 pthread_mutex_unlock(&impl);
207 typedef LPCRITICAL_SECTION native_handle_type;
209 typedef pthread_mutex_t* native_handle_type;
211 native_handle_type native_handle() {
return (native_handle_type) &impl; }
220 CRITICAL_SECTION impl;
223 pthread_mutex_t impl;
235 void set_state( state_t to ) { state = to; }
244 #undef __TBB_mutex_H_include_area