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

scheduling_mode.h 2.7 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. {
  22. ABSL_NAMESPACE_BEGIN
  23. namespace base_internal
  24. {
  25. // Used to describe how a thread may be scheduled. Typically associated with
  26. // the declaration of a resource supporting synchronized access.
  27. //
  28. // SCHEDULE_COOPERATIVE_AND_KERNEL:
  29. // Specifies that when waiting, a cooperative thread (e.g. a Fiber) may
  30. // reschedule (using base::scheduling semantics); allowing other cooperative
  31. // threads to proceed.
  32. //
  33. // SCHEDULE_KERNEL_ONLY: (Also described as "non-cooperative")
  34. // Specifies that no cooperative scheduling semantics may be used, even if the
  35. // current thread is itself cooperatively scheduled. This means that
  36. // cooperative threads will NOT allow other cooperative threads to execute in
  37. // their place while waiting for a resource of this type. Host operating system
  38. // semantics (e.g. a futex) may still be used.
  39. //
  40. // When optional, clients should strongly prefer SCHEDULE_COOPERATIVE_AND_KERNEL
  41. // by default. SCHEDULE_KERNEL_ONLY should only be used for resources on which
  42. // base::scheduling (e.g. the implementation of a Scheduler) may depend.
  43. //
  44. // NOTE: Cooperative resources may not be nested below non-cooperative ones.
  45. // This means that it is invalid to to acquire a SCHEDULE_COOPERATIVE_AND_KERNEL
  46. // resource if a SCHEDULE_KERNEL_ONLY resource is already held.
  47. enum SchedulingMode
  48. {
  49. SCHEDULE_KERNEL_ONLY = 0, // Allow scheduling only the host OS.
  50. SCHEDULE_COOPERATIVE_AND_KERNEL, // Also allow cooperative scheduling.
  51. };
  52. } // namespace base_internal
  53. ABSL_NAMESPACE_END
  54. } // namespace absl
  55. #endif // ABSL_BASE_INTERNAL_SCHEDULING_MODE_H_