File indexing completed on 2026-04-01 07:59:15
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 #ifndef BOOST_CONFIG_HPP
0025 # include <boost/config.hpp>
0026 #endif
0027 0028 ">#
0029 #if defined(BOOST_HAS_PRAGMA_ONCE)
0030 # pragma once
0031 #endif
0032
0033 #ifndef BOOST_CONTAINER_DETAIL_THREAD_MUTEX_HPP
0034 #define BOOST_CONTAINER_DETAIL_THREAD_MUTEX_HPP
0035
0036 #include <boost/container/detail/config_begin.hpp>
0037 #include <boost/container/detail/workaround.hpp>
0038
0039 #if defined(BOOST_HAS_PTHREADS)
0040
0041 #include <pthread.h>
0042 #include <boost/assert.hpp>
0043
0044 namespace boost{
0045 namespace container {
0046 namespace dtl {
0047
0048 class thread_mutex
0049 {
0050 public:
0051 thread_mutex()
0052 {
0053 BOOST_VERIFY(pthread_mutex_init(&m_mut, 0) == 0);
0054 }
0055
0056 ~thread_mutex()
0057 {
0058 BOOST_VERIFY(pthread_mutex_destroy(&m_mut) == 0);
0059 }
0060
0061 void lock()
0062 {
0063 BOOST_VERIFY(pthread_mutex_lock( &m_mut) == 0);
0064 }
0065
0066 void unlock()
0067 {
0068 BOOST_VERIFY(pthread_mutex_unlock(&m_mut) == 0);
0069 }
0070
0071 private:
0072 thread_mutex(thread_mutex const &);
0073 thread_mutex & operator=(thread_mutex const &);
0074
0075 pthread_mutex_t m_mut;
0076 };
0077
0078 }
0079 }
0080 }
0081
0082 #else
0083
0084 #ifdef BOOST_USE_WINDOWS_H
0085
0086 #include <windows.h>
0087
0088 namespace boost{
0089 namespace container {
0090 namespace dtl {
0091
0092 typedef ::CRITICAL_SECTION win_critical_section;
0093
0094 }
0095 }
0096 }
0097
0098 #else
0099
0100 struct _RTL_CRITICAL_SECTION_DEBUG;
0101 struct _RTL_CRITICAL_SECTION;
0102
0103 namespace boost{
0104 namespace container {
0105 namespace dtl {
0106
0107 #ifdef BOOST_PLAT_WINDOWS_UWP
0108 extern "C" __declspec(dllimport) int __stdcall InitializeCriticalSectionEx(::_RTL_CRITICAL_SECTION *, unsigned long, unsigned long);
0109 #else
0110 extern "C" __declspec(dllimport) void __stdcall InitializeCriticalSection(::_RTL_CRITICAL_SECTION *);
0111 #endif
0112 extern "C" __declspec(dllimport) void __stdcall EnterCriticalSection(::_RTL_CRITICAL_SECTION *);
0113 extern "C" __declspec(dllimport) void __stdcall LeaveCriticalSection(::_RTL_CRITICAL_SECTION *);
0114 extern "C" __declspec(dllimport) void __stdcall DeleteCriticalSection(::_RTL_CRITICAL_SECTION *);
0115
0116 struct win_critical_section
0117 {
0118 struct _RTL_CRITICAL_SECTION_DEBUG * DebugInfo;
0119 long LockCount;
0120 long RecursionCount;
0121 void * OwningThread;
0122 void * LockSemaphore;
0123 #if defined(_WIN64)
0124 unsigned __int64 SpinCount;
0125 #else
0126 unsigned long SpinCount;
0127 #endif
0128 };
0129
0130 }
0131 }
0132 }
0133
0134 #endif
0135
0136 namespace boost{
0137 namespace container {
0138 namespace dtl {
0139
0140 class thread_mutex
0141 {
0142 public:
0143 thread_mutex()
0144 {
0145 #ifdef BOOST_PLAT_WINDOWS_UWP
0146 (InitializeCriticalSectionEx)(reinterpret_cast< ::_RTL_CRITICAL_SECTION* >(&m_crit_sect), 4000, 0);
0147 #else
0148 (InitializeCriticalSection)(reinterpret_cast< ::_RTL_CRITICAL_SECTION* >(&m_crit_sect));
0149 #endif
0150 }
0151
0152 void lock()
0153 {
0154 (EnterCriticalSection)(reinterpret_cast< ::_RTL_CRITICAL_SECTION* >(&m_crit_sect));
0155 }
0156
0157 void unlock()
0158 {
0159 (LeaveCriticalSection)(reinterpret_cast< ::_RTL_CRITICAL_SECTION* >(&m_crit_sect));
0160 }
0161
0162 ~thread_mutex()
0163 {
0164 (DeleteCriticalSection)(reinterpret_cast< ::_RTL_CRITICAL_SECTION* >(&m_crit_sect));
0165 }
0166
0167 private:
0168 thread_mutex(thread_mutex const &);
0169 thread_mutex & operator=(thread_mutex const &);
0170
0171 win_critical_section m_crit_sect;
0172 };
0173
0174 }
0175 }
0176 }
0177
0178 #endif
0179
0180 #include <boost/container/detail/config_end.hpp>
0181
0182 #endif