Panda3D
mutexWin32Impl.I
1 // Filename: mutexWin32Impl.I
2 // Created by: drose (07Feb06)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: MutexWin32Impl::Destructor
18 // Access: Public
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE MutexWin32Impl::
22 ~MutexWin32Impl() {
23  DeleteCriticalSection(&_lock);
24 }
25 
26 ////////////////////////////////////////////////////////////////////
27 // Function: MutexWin32Impl::acquire
28 // Access: Public
29 // Description:
30 ////////////////////////////////////////////////////////////////////
31 INLINE void MutexWin32Impl::
32 acquire() {
33  EnterCriticalSection(&_lock);
34 }
35 
36 ////////////////////////////////////////////////////////////////////
37 // Function: MutexWin32Impl::try_acquire
38 // Access: Public
39 // Description:
40 ////////////////////////////////////////////////////////////////////
41 INLINE bool MutexWin32Impl::
42 try_acquire() {
43  return (TryEnterCriticalSection(&_lock) != 0);
44 }
45 
46 ////////////////////////////////////////////////////////////////////
47 // Function: MutexWin32Impl::release
48 // Access: Public
49 // Description:
50 ////////////////////////////////////////////////////////////////////
51 INLINE void MutexWin32Impl::
52 release() {
53  LeaveCriticalSection(&_lock);
54 }