Bullet Collision Detection & Physics Library
btThreads.h
Go to the documentation of this file.
1 /*
2 Copyright (c) 2003-2014 Erwin Coumans http://bullet.googlecode.com
3 
4 This software is provided 'as-is', without any express or implied warranty.
5 In no event will the authors be held liable for any damages arising from the use of this software.
6 Permission is granted to anyone to use this software for any purpose,
7 including commercial applications, and to alter it and redistribute it freely,
8 subject to the following restrictions:
9 
10 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
11 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
12 3. This notice may not be removed or altered from any source distribution.
13 */
14 
15 
16 
17 #ifndef BT_THREADS_H
18 #define BT_THREADS_H
19 
20 #include "btScalar.h" // has definitions like SIMD_FORCE_INLINE
21 
29 {
30  int mLock;
31 
32 public:
34  {
35  mLock = 0;
36  }
37  void lock();
38  void unlock();
39  bool tryLock();
40 };
41 
42 #if BT_THREADSAFE
43 
44 // for internal Bullet use only
46 {
47  mutex->lock();
48 }
49 
51 {
52  mutex->unlock();
53 }
54 
56 {
57  return mutex->tryLock();
58 }
59 
60 // for internal use only
61 bool btIsMainThread();
62 unsigned int btGetCurrentThreadIndex();
63 const unsigned int BT_MAX_THREAD_COUNT = 64;
64 
65 #else
66 
67 // for internal Bullet use only
68 // if BT_THREADSAFE is undefined or 0, should optimize away to nothing
72 #endif
73 
74 
75 #endif //BT_THREADS_H
void btMutexLock(btSpinMutex *)
Definition: btThreads.h:69
bool tryLock()
Definition: btThreads.cpp:223
#define SIMD_FORCE_INLINE
Definition: btScalar.h:64
btSpinMutex – lightweight spin-mutex implemented with atomic ops, never puts a thread to sleep beca...
Definition: btThreads.h:28
bool btMutexTryLock(btSpinMutex *)
Definition: btThreads.h:71
void lock()
Definition: btThreads.cpp:213
void unlock()
Definition: btThreads.cpp:218
void btMutexUnlock(btSpinMutex *)
Definition: btThreads.h:70