summaryrefslogtreecommitdiff
path: root/thirdparty/bullet/LinearMath/btThreads.h
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/bullet/LinearMath/btThreads.h')
-rw-r--r--thirdparty/bullet/LinearMath/btThreads.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/thirdparty/bullet/LinearMath/btThreads.h b/thirdparty/bullet/LinearMath/btThreads.h
index 05fd15ec82..921fd088c0 100644
--- a/thirdparty/bullet/LinearMath/btThreads.h
+++ b/thirdparty/bullet/LinearMath/btThreads.h
@@ -28,6 +28,8 @@ subject to the following restrictions:
#define BT_OVERRIDE
#endif
+// Don't set this to larger than 64, without modifying btThreadSupportPosix
+// and btThreadSupportWin32. They use UINT64 bit-masks.
const unsigned int BT_MAX_THREAD_COUNT = 64; // only if BT_THREADSAFE is 1
// for internal use only
@@ -72,6 +74,8 @@ SIMD_FORCE_INLINE void btMutexLock( btSpinMutex* mutex )
{
#if BT_THREADSAFE
mutex->lock();
+#else
+ (void)mutex;
#endif // #if BT_THREADSAFE
}
@@ -79,6 +83,8 @@ SIMD_FORCE_INLINE void btMutexUnlock( btSpinMutex* mutex )
{
#if BT_THREADSAFE
mutex->unlock();
+#else
+ (void)mutex;
#endif // #if BT_THREADSAFE
}
@@ -87,6 +93,7 @@ SIMD_FORCE_INLINE bool btMutexTryLock( btSpinMutex* mutex )
#if BT_THREADSAFE
return mutex->tryLock();
#else
+ (void)mutex;
return true;
#endif // #if BT_THREADSAFE
}
@@ -103,6 +110,17 @@ public:
};
//
+// btIParallelSumBody -- subclass this to express work that can be done in parallel
+// and produces a sum over all loop elements
+//
+class btIParallelSumBody
+{
+public:
+ virtual ~btIParallelSumBody() {}
+ virtual btScalar sumLoop( int iBegin, int iEnd ) const = 0;
+};
+
+//
// btITaskScheduler -- subclass this to implement a task scheduler that can dispatch work to
// worker threads
//
@@ -117,6 +135,8 @@ public:
virtual int getNumThreads() const = 0;
virtual void setNumThreads( int numThreads ) = 0;
virtual void parallelFor( int iBegin, int iEnd, int grainSize, const btIParallelForBody& body ) = 0;
+ virtual btScalar parallelSum( int iBegin, int iEnd, int grainSize, const btIParallelSumBody& body ) = 0;
+ virtual void sleepWorkerThreadsHint() {} // hint the task scheduler that we may not be using these threads for a little while
// internal use only
virtual void activate();
@@ -138,6 +158,9 @@ btITaskScheduler* btGetTaskScheduler();
// get non-threaded task scheduler (always available)
btITaskScheduler* btGetSequentialTaskScheduler();
+// create a default task scheduler (Win32 or pthreads based)
+btITaskScheduler* btCreateDefaultTaskScheduler();
+
// get OpenMP task scheduler (if available, otherwise returns null)
btITaskScheduler* btGetOpenMPTaskScheduler();
@@ -151,5 +174,9 @@ btITaskScheduler* btGetPPLTaskScheduler();
// (iterations may be done out of order, so no dependencies are allowed)
void btParallelFor( int iBegin, int iEnd, int grainSize, const btIParallelForBody& body );
+// btParallelSum -- call this to dispatch work like a for-loop, returns the sum of all iterations
+// (iterations may be done out of order, so no dependencies are allowed)
+btScalar btParallelSum( int iBegin, int iEnd, int grainSize, const btIParallelSumBody& body );
+
#endif