Bullet Collision Detection & Physics Library: btThreadSupportInterface.h Source File

Bullet Collision Detection & Physics Library

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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