00001 // Copyright 2017 The Abseil Authors. 00002 // 00003 // Licensed under the Apache License, Version 2.0 (the "License"); 00004 // you may not use this file except in compliance with the License. 00005 // You may obtain a copy of the License at 00006 // 00007 // https://www.apache.org/licenses/LICENSE-2.0 00008 // 00009 // Unless required by applicable law or agreed to in writing, software 00010 // distributed under the License is distributed on an "AS IS" BASIS, 00011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00012 // See the License for the specific language governing permissions and 00013 // limitations under the License. 00014 // 00015 // Core interfaces and definitions used by by low-level interfaces such as 00016 // SpinLock. 00017 00018 #ifndef ABSL_BASE_INTERNAL_SCHEDULING_MODE_H_ 00019 #define ABSL_BASE_INTERNAL_SCHEDULING_MODE_H_ 00020 00021 namespace absl { 00022 namespace base_internal { 00023 00024 // Used to describe how a thread may be scheduled. Typically associated with 00025 // the declaration of a resource supporting synchronized access. 00026 // 00027 // SCHEDULE_COOPERATIVE_AND_KERNEL: 00028 // Specifies that when waiting, a cooperative thread (e.g. a Fiber) may 00029 // reschedule (using base::scheduling semantics); allowing other cooperative 00030 // threads to proceed. 00031 // 00032 // SCHEDULE_KERNEL_ONLY: (Also described as "non-cooperative") 00033 // Specifies that no cooperative scheduling semantics may be used, even if the 00034 // current thread is itself cooperatively scheduled. This means that 00035 // cooperative threads will NOT allow other cooperative threads to execute in 00036 // their place while waiting for a resource of this type. Host operating system 00037 // semantics (e.g. a futex) may still be used. 00038 // 00039 // When optional, clients should strongly prefer SCHEDULE_COOPERATIVE_AND_KERNEL 00040 // by default. SCHEDULE_KERNEL_ONLY should only be used for resources on which 00041 // base::scheduling (e.g. the implementation of a Scheduler) may depend. 00042 // 00043 // NOTE: Cooperative resources may not be nested below non-cooperative ones. 00044 // This means that it is invalid to to acquire a SCHEDULE_COOPERATIVE_AND_KERNEL 00045 // resource if a SCHEDULE_KERNEL_ONLY resource is already held. 00046 enum SchedulingMode { 00047 SCHEDULE_KERNEL_ONLY = 0, // Allow scheduling only the host OS. 00048 SCHEDULE_COOPERATIVE_AND_KERNEL, // Also allow cooperative scheduling. 00049 }; 00050 00051 } // namespace base_internal 00052 } // namespace absl 00053 00054 #endif // ABSL_BASE_INTERNAL_SCHEDULING_MODE_H_