You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

null_mutex.h 618B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //
  2. // Copyright(c) 2015 Gabi Melman.
  3. // Distributed under the MIT License (http://opensource.org/licenses/MIT)
  4. //
  5. #pragma once
  6. #include <atomic>
  7. // null, no cost dummy "mutex" and dummy "atomic" int
  8. namespace spdlog
  9. {
  10. namespace details
  11. {
  12. struct null_mutex
  13. {
  14. void lock() {}
  15. void unlock() {}
  16. bool try_lock()
  17. {
  18. return true;
  19. }
  20. };
  21. struct null_atomic_int
  22. {
  23. int value;
  24. null_atomic_int() = default;
  25. null_atomic_int(int val):value(val)
  26. {}
  27. int load(std::memory_order) const
  28. {
  29. return value;
  30. }
  31. void store(int val)
  32. {
  33. value = val;
  34. }
  35. };
  36. }
  37. }