ThreadPoolMacros.h 838 B

123456789101112131415161718192021222324252627
  1. #pragma once
  2. #include "os/Atomic.h"
  3. #define COUNTER_CHECK(counter) \
  4. do { \
  5. IL2CPP_ASSERT(counter._.max_working > 0); \
  6. IL2CPP_ASSERT(counter._.working >= 0); \
  7. IL2CPP_ASSERT(counter._.active >= 0); \
  8. } while (0)
  9. #define COUNTER_READ() (il2cpp::os::Atomic::Read64 (&g_ThreadPool->counters.as_int64_t))
  10. #define COUNTER_ATOMIC(var, block) \
  11. do { \
  12. ThreadPoolCounter __old; \
  13. do { \
  14. IL2CPP_ASSERT(g_ThreadPool); \
  15. __old.as_int64_t = COUNTER_READ (); \
  16. (var) = __old; \
  17. { block; } \
  18. COUNTER_CHECK (var); \
  19. } while (il2cpp::os::Atomic::CompareExchange64 (&g_ThreadPool->counters.as_int64_t, (var).as_int64_t, __old.as_int64_t) != __old.as_int64_t); \
  20. } while (0)
  21. #define CPU_USAGE_LOW 80
  22. #define CPU_USAGE_HIGH 95