Baselib_WakeupFallbackStrategy.h 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. #pragma once
  2. #include "Internal/Baselib_EnumSizeCheck.h"
  3. #ifdef __cplusplus
  4. BASELIB_C_INTERFACE
  5. {
  6. #endif
  7. // Can be used to control the wakeup behavior on platforms that don't support waking up a specific number of thread.
  8. // Syscalls don't come for free so you need to weigh the cost of doing multiple syscalls against the cost of having lots of context switches.
  9. //
  10. // There are however two easy cases.
  11. // * When you only want to notify one thread use Baselib_WakeupFallbackStrategy_OneByOne.
  12. // * When you want to wakeup all threads use Baselib_WakeupFallbackStrategy_All
  13. //
  14. // For the not so easy cases.
  15. // * Use Baselib_WakeupFallbackStrategy_OneByOne when wake count is low, or significantly lower than the number of waiting threads.
  16. // * Use Baselib_WakeupFallbackStrategy_All if wake count is high.
  17. typedef enum Baselib_WakeupFallbackStrategy
  18. {
  19. // Do one syscall for each waiting thread or notification.
  20. Baselib_WakeupFallbackStrategy_OneByOne,
  21. // Do a single syscall to wake all waiting threads.
  22. Baselib_WakeupFallbackStrategy_All,
  23. } Baselib_WakeupFallbackStrategy;
  24. BASELIB_ENUM_ENSURE_ABI_COMPATIBILITY(Baselib_WakeupFallbackStrategy);
  25. #ifdef __cplusplus
  26. } // BASELIB_C_INTERFACE
  27. #endif