Bullet Collision Detection & Physics Library
btThreadSupportInterface.h
Go to the documentation of this file.
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2018 Erwin Coumans http://bulletphysics.com
4 
5 This software is provided 'as-is', without any express or implied warranty.
6 In no event will the authors be held liable for any damages arising from the use of this software.
7 Permission is granted to anyone to use this software for any purpose,
8 including commercial applications, and to alter it and redistribute it freely,
9 subject to the following restrictions:
10 
11 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.
12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13 3. This notice may not be removed or altered from any source distribution.
14 */
15 
16 #ifndef BT_THREAD_SUPPORT_INTERFACE_H
17 #define BT_THREAD_SUPPORT_INTERFACE_H
18 
19 
20 
22 {
23 public:
25  virtual ~btCriticalSection() {}
26 
27  virtual void lock() = 0;
28  virtual void unlock() = 0;
29 };
30 
31 
33 {
34 public:
35 
37 
38  virtual int getNumWorkerThreads() const = 0; // number of worker threads (total number of logical processors - 1)
39  virtual int getCacheFriendlyNumThreads() const = 0; // the number of logical processors sharing a single L3 cache
40  virtual int getLogicalToPhysicalCoreRatio() const = 0; // the number of logical processors per physical processor (usually 1 or 2)
41  virtual void runTask( int threadIndex, void* userData ) = 0;
42  virtual void waitForAllTasks() = 0;
43 
44  virtual btCriticalSection* createCriticalSection() = 0;
45  virtual void deleteCriticalSection( btCriticalSection* criticalSection ) = 0;
46 
47  typedef void( *ThreadFunc )( void* userPtr );
48 
50  {
51  ConstructionInfo( const char* uniqueName,
52  ThreadFunc userThreadFunc,
53  int threadStackSize = 65535
54  )
55  :m_uniqueName( uniqueName ),
56  m_userThreadFunc( userThreadFunc ),
57  m_threadStackSize( threadStackSize )
58  {
59  }
60 
61  const char* m_uniqueName;
62  ThreadFunc m_userThreadFunc;
64  };
65 
66  static btThreadSupportInterface* create( const ConstructionInfo& info );
67 };
68 
69 #endif //BT_THREAD_SUPPORT_INTERFACE_H
70 
virtual void unlock()=0
virtual void lock()=0
ConstructionInfo(const char *uniqueName, ThreadFunc userThreadFunc, int threadStackSize=65535)