[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-physics / third-party / bullet3 / src / LinearMath / TaskScheduler / btThreadSupportInterface.h
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 class btCriticalSection
20 {
21 public:
22         btCriticalSection() {}
23         virtual ~btCriticalSection() {}
24
25         virtual void lock() = 0;
26         virtual void unlock() = 0;
27 };
28
29 class btThreadSupportInterface
30 {
31 public:
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