STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Classes | Public Member Functions | Private Attributes | List of all members
msclr::lock Class Reference

#include <msclr/lock.h>

Classes

struct  is_not
 
struct  is_not< T, T >
 

Public Member Functions

template<class T >
 lock (T^_object)
 
template<class T >
 lock (T^_object, int _timeout)
 
template<class T >
 lock (T^_object, System::TimeSpan _timeout)
 
template<class T >
 lock (T^_object, lock_when)
 
template<class T >
 lock (gcroot< T^> _object)
 
template<class T >
 lock (gcroot< T^> _object, int _timeout)
 
template<class T >
 lock (gcroot< T^> _object, System::TimeSpan _timeout)
 
template<class T >
 lock (gcroot< T^> _object, lock_when)
 
 ~lock ()
 
bool is_locked ()
 
 operator _detail_class::_safe_bool ()
 
template<class T >
bool operator== (T t)
 
template<class T >
bool operator!= (T t)
 
void acquire (int _timeout)
 
void acquire ()
 
void acquire (System::TimeSpan _timeout)
 
bool try_acquire (int _timeout)
 
bool try_acquire (System::TimeSpan _timeout)
 
void release ()
 

Private Attributes

System::Object m_object
 
bool m_locked
 

Constructor & Destructor Documentation

template<class T >
msclr::lock::lock ( T^  _object)
inline
46  : m_object( _object ),
47  m_locked( false )
48  {
49  // ensure that T is not a ReaderWriterLock.
50  typedef is_not<T, System::Threading::ReaderWriterLock>::__dont_use_this_type__ _Diagnostic;
51 
52  acquire(System::Threading::Timeout::Infinite);
53  }
bool m_locked
Definition: lock.h:37
System::Object m_object
Definition: lock.h:36
void acquire()
Definition: lock.h:182
template<class T >
msclr::lock::lock ( T^  _object,
int  _timeout 
)
inline
56  : m_object( _object ),
57  m_locked( false )
58  {
59  // ensure that T is not a ReaderWriterLock.
60  typedef is_not<T, System::Threading::ReaderWriterLock>::__dont_use_this_type__ _Diagnostic;
61 
62  acquire( _timeout );
63  }
bool m_locked
Definition: lock.h:37
System::Object m_object
Definition: lock.h:36
void acquire()
Definition: lock.h:182
template<class T >
msclr::lock::lock ( T^  _object,
System::TimeSpan  _timeout 
)
inline
68  : m_object( _object ),
69  m_locked( false )
70  {
71  // ensure that T is not a ReaderWriterLock.
72  typedef is_not<T, System::Threading::ReaderWriterLock>::__dont_use_this_type__ _Diagnostic;
73 
74  acquire( _timeout );
75  }
bool m_locked
Definition: lock.h:37
System::Object m_object
Definition: lock.h:36
void acquire()
Definition: lock.h:182
template<class T >
msclr::lock::lock ( T^  _object,
lock_when   
)
inline
80  : m_object( _object ),
81  m_locked( false )
82  {
83  // ensure that T is not a ReaderWriterLock.
84  typedef is_not<T, System::Threading::ReaderWriterLock>::__dont_use_this_type__ _Diagnostic;
85  }
bool m_locked
Definition: lock.h:37
System::Object m_object
Definition: lock.h:36
template<class T >
msclr::lock::lock ( gcroot< T^>  _object)
inline
89  : m_object( _object ),
90  m_locked( false )
91  {
92  // ensure that T is not a ReaderWriterLock.
93  typedef is_not<T, System::Threading::ReaderWriterLock>::__dont_use_this_type__ _Diagnostic;
94 
95  acquire(System::Threading::Timeout::Infinite);
96  }
bool m_locked
Definition: lock.h:37
System::Object m_object
Definition: lock.h:36
void acquire()
Definition: lock.h:182
template<class T >
msclr::lock::lock ( gcroot< T^>  _object,
int  _timeout 
)
inline
100  : m_object( _object ),
101  m_locked( false )
102  {
103  // ensure that T is not a ReaderWriterLock.
104  typedef is_not<T, System::Threading::ReaderWriterLock>::__dont_use_this_type__ _Diagnostic;
105 
106  acquire( _timeout );
107  }
bool m_locked
Definition: lock.h:37
System::Object m_object
Definition: lock.h:36
void acquire()
Definition: lock.h:182
template<class T >
msclr::lock::lock ( gcroot< T^>  _object,
System::TimeSpan  _timeout 
)
inline
112  : m_object( _object ),
113  m_locked( false )
114  {
115  // ensure that T is not a ReaderWriterLock.
116  typedef is_not<T, System::Threading::ReaderWriterLock>::__dont_use_this_type__ _Diagnostic;
117 
118  acquire( _timeout );
119  }
bool m_locked
Definition: lock.h:37
System::Object m_object
Definition: lock.h:36
void acquire()
Definition: lock.h:182
template<class T >
msclr::lock::lock ( gcroot< T^>  _object,
lock_when   
)
inline
124  : m_object( _object ),
125  m_locked( false )
126  {
127  // ensure that T is not a ReaderWriterLock.
128  typedef is_not<T, System::Threading::ReaderWriterLock>::__dont_use_this_type__ _Diagnostic;
129  }
bool m_locked
Definition: lock.h:37
System::Object m_object
Definition: lock.h:36
msclr::lock::~lock ( )
inline
134  {
135  release();
136  }
void release()
Definition: lock.h:242

Member Function Documentation

void msclr::lock::acquire ( int  _timeout)
inline
170  {
171  if( ! m_locked )
172  {
173  System::Threading::Monitor::TryEnter( m_object, _timeout, m_locked );
174  if( ! m_locked )
175  {
176  static const long _hresult_wait_timeout = 0x80070102;
177  throw System::Runtime::InteropServices::Marshal::GetExceptionForHR( _hresult_wait_timeout );
178  }
179  }
180  }
bool m_locked
Definition: lock.h:37
System::Object m_object
Definition: lock.h:36
void msclr::lock::acquire ( )
inline
183  {
184  if( ! m_locked )
185  {
186  System::Threading::Monitor::TryEnter( m_object,
187  System::Threading::Timeout::Infinite, m_locked );
188  if( ! m_locked )
189  {
190  static const long _hresult_wait_timeout = 0x80070102;
191  throw System::Runtime::InteropServices::Marshal::GetExceptionForHR( _hresult_wait_timeout );
192  }
193  }
194  }
bool m_locked
Definition: lock.h:37
System::Object m_object
Definition: lock.h:36
void msclr::lock::acquire ( System::TimeSpan  _timeout)
inline
199  {
200  if( ! m_locked )
201  {
202  System::Threading::Monitor::TryEnter( m_object, _timeout, m_locked );
203  if( ! m_locked )
204  {
205  static const long _hresult_wait_timeout = 0x80070102;
206  throw System::Runtime::InteropServices::Marshal::GetExceptionForHR( _hresult_wait_timeout );
207  }
208  }
209  }
bool m_locked
Definition: lock.h:37
System::Object m_object
Definition: lock.h:36
bool msclr::lock::is_locked ( )
inline
140  {
141  return m_locked;
142  }
bool m_locked
Definition: lock.h:37
msclr::lock::operator _detail_class::_safe_bool ( )
inline
146  {
148  }
static _safe_bool const _safe_false
Definition: safebool.h:39
static _safe_bool const _safe_true
Definition: safebool.h:38
bool is_locked()
Definition: lock.h:139
template<class T >
bool msclr::lock::operator!= ( t)
inline
160  {
161  // ensure that T is not a _safe_bool.
162  typedef is_not<T, _detail_class::_safe_bool>::__dont_use_this_type__ _Diagnostic;
163 
164  return m_object != t;
165  }
System::Object m_object
Definition: lock.h:36
template<class T >
bool msclr::lock::operator== ( t)
inline
152  {
153  // ensure that T is not a _safe_bool.
154  typedef is_not<T, _detail_class::_safe_bool>::__dont_use_this_type__ _Diagnostic;
155 
156  return m_object == t;
157  }
System::Object m_object
Definition: lock.h:36
void msclr::lock::release ( )
inline
243  {
244  if( m_locked )
245  {
246  System::Threading::Monitor::Exit( m_object );
247  m_locked = false;
248  }
249  }
bool m_locked
Definition: lock.h:37
System::Object m_object
Definition: lock.h:36
bool msclr::lock::try_acquire ( int  _timeout)
inline
214  {
215  if( ! m_locked )
216  {
217  System::Threading::Monitor::TryEnter( m_object, _timeout, m_locked );
218  if( ! m_locked )
219  {
220  return false;
221  }
222  }
223  return true;
224  }
bool m_locked
Definition: lock.h:37
System::Object m_object
Definition: lock.h:36
bool msclr::lock::try_acquire ( System::TimeSpan  _timeout)
inline
229  {
230  if( ! m_locked )
231  {
232  System::Threading::Monitor::TryEnter( m_object, _timeout, m_locked );
233  if( ! m_locked )
234  {
235  return false;
236  }
237  }
238  return true;
239  }
bool m_locked
Definition: lock.h:37
System::Object m_object
Definition: lock.h:36

Member Data Documentation

bool msclr::lock::m_locked
private
System::Object msclr::lock::m_object
private

The documentation for this class was generated from the following file: