b3ThreadSupportInterface.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. Bullet Continuous Collision Detection and Physics Library
  3. Copyright (c) 2003-2007 Erwin Coumans http://bulletphysics.com
  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. 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.
  10. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
  11. 3. This notice may not be removed or altered from any source distribution.
  12. */
  13. #ifndef B3_THREAD_SUPPORT_INTERFACE_H
  14. #define B3_THREAD_SUPPORT_INTERFACE_H
  15. enum
  16. {
  17. B3_THREAD_SCHEDULE_TASK=1,
  18. };
  19. #include "Bullet3Common/b3Scalar.h" //for B3_ATTRIBUTE_ALIGNED16
  20. //#include "PlatformDefinitions.h"
  21. //#include "PpuAddressSpace.h"
  22. class b3Barrier {
  23. public:
  24. b3Barrier() {}
  25. virtual ~b3Barrier() {}
  26. virtual void sync() = 0;
  27. virtual void setMaxCount(int n) = 0;
  28. virtual int getMaxCount() = 0;
  29. };
  30. class b3CriticalSection {
  31. public:
  32. b3CriticalSection() {}
  33. virtual ~b3CriticalSection() {}
  34. B3_ATTRIBUTE_ALIGNED16(unsigned int mCommonBuff[32]);
  35. virtual unsigned int getSharedParam(int i) = 0;
  36. virtual void setSharedParam(int i,unsigned int p) = 0;
  37. virtual void lock() = 0;
  38. virtual void unlock() = 0;
  39. };
  40. class b3ThreadSupportInterface
  41. {
  42. public:
  43. virtual ~b3ThreadSupportInterface();
  44. virtual void runTask(int uiCommand, void* uiArgument0, int uiArgument1) =0;
  45. virtual void waitForResponse(int *puiArgument0, int *puiArgument1) =0;
  46. ///non-blocking test if a task is completed. First implement all versions, and then enable this API
  47. virtual bool isTaskCompleted(int *puiArgument0, int *puiArgument1, int timeOutInMilliseconds)=0;
  48. virtual void stopThreads()=0;
  49. ///tell the task scheduler to use no more than numTasks tasks
  50. virtual void setNumTasks(int numTasks)=0;
  51. virtual int getNumTasks() const = 0;
  52. virtual b3Barrier* createBarrier() = 0;
  53. virtual b3CriticalSection* createCriticalSection() = 0;
  54. virtual void deleteBarrier(b3Barrier* barrier)=0;
  55. virtual void deleteCriticalSection(b3CriticalSection* criticalSection)=0;
  56. virtual void* getThreadLocalMemory(int taskId) { return 0; }
  57. };
  58. #endif //B3_THREAD_SUPPORT_INTERFACE_H