BsThreadDefines.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #define BS_AUTO_MUTEX_NAME mutex
  5. #include <thread>
  6. #include <chrono>
  7. #include <mutex>
  8. #include <condition_variable>
  9. #include "Threading/BsSpinLock.h"
  10. /** @addtogroup Threading
  11. * @{
  12. */
  13. /** Returns the number of logical CPU cores. */
  14. #define BS_THREAD_HARDWARE_CONCURRENCY std::thread::hardware_concurrency()
  15. /** Returns the ThreadId of the current thread. */
  16. #define BS_THREAD_CURRENT_ID std::this_thread::get_id()
  17. /** Causes the current thread to sleep for the provided amount of milliseconds. */
  18. #define BS_THREAD_SLEEP(ms) std::this_thread::sleep_for(std::chrono::milliseconds(ms));
  19. /** Wrapper for the C++ std::mutex. */
  20. using Mutex = std::mutex;
  21. /** Wrapper for the C++ std::recursive_mutex. */
  22. using RecursiveMutex = std::recursive_mutex;
  23. /** Wrapper for the C++ std::condition_variable. */
  24. using Signal = std::condition_variable;
  25. /** Wrapper for the C++ std::thread. */
  26. using Thread = std::thread;
  27. /** Wrapper for the C++ std::thread::id. */
  28. using ThreadId = std::thread::id;
  29. /** Wrapper for the C++ std::unique_lock<std::mutex>. */
  30. using Lock = std::unique_lock<Mutex>;
  31. /** Wrapper for the C++ std::unique_lock<std::recursive_mutex>. */
  32. using RecursiveLock = std::unique_lock<RecursiveMutex>;
  33. /** @} */