scheduling_mode.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright 2017 The Abseil Authors.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // https://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. //
  15. // Core interfaces and definitions used by by low-level interfaces such as
  16. // SpinLock.
  17. #ifndef ABSL_BASE_INTERNAL_SCHEDULING_MODE_H_
  18. #define ABSL_BASE_INTERNAL_SCHEDULING_MODE_H_
  19. #include "absl/base/config.h"
  20. namespace absl {
  21. ABSL_NAMESPACE_BEGIN
  22. namespace base_internal {
  23. // Used to describe how a thread may be scheduled. Typically associated with
  24. // the declaration of a resource supporting synchronized access.
  25. //
  26. // SCHEDULE_COOPERATIVE_AND_KERNEL:
  27. // Specifies that when waiting, a cooperative thread (e.g. a Fiber) may
  28. // reschedule (using base::scheduling semantics); allowing other cooperative
  29. // threads to proceed.
  30. //
  31. // SCHEDULE_KERNEL_ONLY: (Also described as "non-cooperative")
  32. // Specifies that no cooperative scheduling semantics may be used, even if the
  33. // current thread is itself cooperatively scheduled. This means that
  34. // cooperative threads will NOT allow other cooperative threads to execute in
  35. // their place while waiting for a resource of this type. Host operating system
  36. // semantics (e.g. a futex) may still be used.
  37. //
  38. // When optional, clients should strongly prefer SCHEDULE_COOPERATIVE_AND_KERNEL
  39. // by default. SCHEDULE_KERNEL_ONLY should only be used for resources on which
  40. // base::scheduling (e.g. the implementation of a Scheduler) may depend.
  41. //
  42. // NOTE: Cooperative resources may not be nested below non-cooperative ones.
  43. // This means that it is invalid to to acquire a SCHEDULE_COOPERATIVE_AND_KERNEL
  44. // resource if a SCHEDULE_KERNEL_ONLY resource is already held.
  45. enum SchedulingMode {
  46. SCHEDULE_KERNEL_ONLY = 0, // Allow scheduling only the host OS.
  47. SCHEDULE_COOPERATIVE_AND_KERNEL, // Also allow cooperative scheduling.
  48. };
  49. } // namespace base_internal
  50. ABSL_NAMESPACE_END
  51. } // namespace absl
  52. #endif // ABSL_BASE_INTERNAL_SCHEDULING_MODE_H_