Класс CurrentSchedulerCurrentScheduler Class
Представляет абстракцию для текущего планировщика, связанного с вызывающим контекстом.Represents an abstraction for the current scheduler associated with the calling context.
СинтаксисSyntax
class CurrentScheduler;
ЧленыMembers
Открытые методыPublic Methods
nameName | ОписаниеDescription |
---|---|
СозданиеCreate | Создает новый планировщик, поведение которого описывается _Policy параметром и прикрепляет его к вызывающему контексту.Creates a new scheduler whose behavior is described by the _Policy parameter and attaches it to the calling context. Вновь созданный планировщик станет текущим планировщиком для вызывающего контекста.The newly created scheduler will become the current scheduler for the calling context. |
CreateScheduleGroupCreateScheduleGroup | Перегружен.Overloaded. Создает новую группу расписаний в планировщике, связанном с вызывающим контекстом.Creates a new schedule group within the scheduler associated with the calling context. Версия, принимающая параметр, _Placement приводит к смещению задач в созданной группе расписаний к выполнению в расположении, указанном этим параметром.The version that takes the parameter _Placement causes tasks within the newly created schedule group to be biased towards executing at the location specified by that parameter. |
ОтсоединитьDetach | Отсоединяет текущий планировщик от вызывающего контекста и восстанавливает ранее присоединенный планировщик в качестве текущего планировщика, если он существует.Detaches the current scheduler from the calling context and restores the previously attached scheduler as the current scheduler, if one exists. После возврата из этого метода контекст вызова управляется планировщиком, который ранее был присоединен к контексту с помощью CurrentScheduler::Create Scheduler::Attach метода или.After this method returns, the calling context is then managed by the scheduler that was previously attached to the context using either the CurrentScheduler::Create or Scheduler::Attach method. |
ПолучитьGet | Возвращает указатель на планировщик, связанный с контекстом вызова, который также называется текущим планировщиком.Returns a pointer to the scheduler associated with the calling context, also referred to as the current scheduler. |
жетнумберофвиртуалпроцессорсGetNumberOfVirtualProcessors | Возвращает текущее число виртуальных процессоров для планировщика, связанного с контекстом вызова.Returns the current number of virtual processors for the scheduler associated with the calling context. |
GetPolicyGetPolicy | Возвращает копию политики, с которой был создан текущий планировщик.Returns a copy of the policy that the current scheduler was created with. |
IdId | Возвращает уникальный идентификатор текущего планировщика.Returns a unique identifier for the current scheduler. |
исаваилаблелокатионIsAvailableLocation | Определяет, доступно ли данное расположение в текущем планировщике.Determines whether a given location is available on the current scheduler. |
регистершутдовневентRegisterShutdownEvent | Приводит к тому, что дескриптор событий Windows, переданный в _ShutdownEvent параметре, получает сигнал, когда планировщик, связанный с текущим контекстом, завершает работу и удаляет себя.Causes the Windows event handle passed in the _ShutdownEvent parameter to be signaled when the scheduler associated with the current context shuts down and destroys itself. В момент получения сигнала о событии все запланированные работы планировщика завершены.At the time the event is signaled, all work that had been scheduled to the scheduler is complete. С помощью этого метода можно зарегистрировать несколько событий завершения работы.Multiple shutdown events can be registered through this method. |
ScheduleTaskScheduleTask | Перегружен.Overloaded. Планирует задачу с невысокой плотностью в планировщике, связанном с вызывающим контекстом.Schedules a light-weight task within the scheduler associated with the calling context. Упрощенная задача будет размещена в группе расписаний, определенной средой выполнения.The light-weight task will be placed in a schedule group determined by the runtime. Версия, принимающая параметр _Placement , склоняет задачу к выполнению в указанном расположении.The version that takes the parameter _Placement causes the task to be biased towards executing at the specified location. |
КомментарииRemarks
Если планировщик (см. раздел Scheduler), связанный с контекстом вызова, отсутствует, многие методы в классе приведут CurrentScheduler
к вложению планировщика процесса по умолчанию.If there is no scheduler (see Scheduler) associated with the calling context, many methods within the CurrentScheduler
class will result in attachment of the process' default scheduler. Это может также предположить, что планировщик процесса по умолчанию создается во время такого вызова.This may also imply that the process' default scheduler is created during such a call.
Иерархия наследованияInheritance Hierarchy
CurrentScheduler
ТребованияRequirements
Заголовок: ConcRT. hHeader: concrt.h
Пространство имен: параллелизмNamespace: concurrency
СозданиеCreate
Создает новый планировщик, поведение которого описывается _Policy
параметром и прикрепляет его к вызывающему контексту.Creates a new scheduler whose behavior is described by the _Policy
parameter and attaches it to the calling context. Вновь созданный планировщик станет текущим планировщиком для вызывающего контекста.The newly created scheduler will become the current scheduler for the calling context.
static void __cdecl Create(const SchedulerPolicy& _Policy);
ПараметрыParameters
_Policy_Policy
Политика планировщика, которая описывает поведение только что созданного планировщика.The scheduler policy that describes the behavior of the newly created scheduler.
КомментарииRemarks
При присоединении планировщика к контексту вызова неявно накладывается счетчик ссылок на планировщик.The attachment of the scheduler to the calling context implicitly places a reference count on the scheduler.
После создания планировщика с помощью Create
метода необходимо вызвать метод CurrentScheduler::D етач в некоторый момент в будущем, чтобы разрешить завершение работы планировщика.After a scheduler is created with the Create
method, you must call the CurrentScheduler::Detach method at some point in the future in order to allow the scheduler to shut down.
Если этот метод вызывается из контекста, уже присоединенного к другому планировщику, существующий планировщик запоминается как предыдущий планировщик, а вновь созданный планировщик становится текущим планировщиком.If this method is called from a context that is already attached to a different scheduler, the existing scheduler is remembered as the previous scheduler, and the newly created scheduler becomes the current scheduler. При CurrentScheduler::Detach
последующем вызове метода предыдущий планировщик восстанавливается в качестве текущего планировщика.When you call the CurrentScheduler::Detach
method at a later point, the previous scheduler is restored as the current scheduler.
Этот метод может вызывать различные исключения, в том числе scheduler_resource_allocation_error и invalid_scheduler_policy_value.This method can throw a variety of exceptions, including scheduler_resource_allocation_error and invalid_scheduler_policy_value.
CreateScheduleGroupCreateScheduleGroup
Создает новую группу расписаний в планировщике, связанном с вызывающим контекстом.Creates a new schedule group within the scheduler associated with the calling context. Версия, принимающая параметр, _Placement
приводит к смещению задач в созданной группе расписаний к выполнению в расположении, указанном этим параметром.The version that takes the parameter _Placement
causes tasks within the newly created schedule group to be biased towards executing at the location specified by that parameter.
static ScheduleGroup* __cdecl CreateScheduleGroup();
static ScheduleGroup* __cdecl CreateScheduleGroup(location& _Placement);
ПараметрыParameters
_Placement_Placement
Ссылка на расположение, в котором задачи в группе расписаний будут смещены в сторону выполнения в.A reference to a location where the tasks within the schedule group will be biased towards executing at.
Возвращаемое значениеReturn Value
Указатель на только что созданную группу расписаний.A pointer to the newly created schedule group. ScheduleGroup
На этом объекте размещено начальное количество ссылок.This ScheduleGroup
object has an initial reference count placed on it.
КомментарииRemarks
В результате этого метода в процессе будет создан планировщик по умолчанию и/или присоединен к вызывающему контексту, если отсутствует планировщик, в данный момент связанный с вызывающим контекстом.This method will result in the process' default scheduler being created and/or attached to the calling context if there is no scheduler currently associated with the calling context.
При завершении планирования работы для группы расписаний необходимо вызвать метод Release .You must invoke the Release method on a schedule group when you are done scheduling work to it. Планировщик удалит группу расписаний после завершения всей работы в очереди.The scheduler will destroy the schedule group when all work queued to it has completed.
Обратите внимание, что если вы явно создали этот планировщик, необходимо освободить все ссылки на группы планирования в нем, прежде чем освободить ссылку на планировщик, отменив текущий контекст.Note that if you explicitly created this scheduler, you must release all references to schedule groups within it, before you release your reference on the scheduler, by detaching the current context from it.
СоединилDetach
Отсоединяет текущий планировщик от вызывающего контекста и восстанавливает ранее присоединенный планировщик в качестве текущего планировщика, если он существует.Detaches the current scheduler from the calling context and restores the previously attached scheduler as the current scheduler, if one exists. После возврата из этого метода контекст вызова управляется планировщиком, который ранее был присоединен к контексту с помощью CurrentScheduler::Create
Scheduler::Attach
метода или.After this method returns, the calling context is then managed by the scheduler that was previously attached to the context using either the CurrentScheduler::Create
or Scheduler::Attach
method.
static void __cdecl Detach();
КомментарииRemarks
Detach
Метод неявно удаляет счетчик ссылок из планировщика.The Detach
method implicitly removes a reference count from the scheduler.
При отсутствии планировщика, присоединенного к контексту вызова, вызов этого метода приведет к возникновению scheduler_not_attached исключения.If there is no scheduler attached to the calling context, calling this method will result in a scheduler_not_attached exception being thrown.
Вызов этого метода из контекста, который является внутренним и управляется планировщиком, или контекст, который был присоединен с помощью метода, отличного от методов Scheduler:: Attach или CurrentScheduler:: Create , приведет к возникновению исключения improper_scheduler_detach .Calling this method from a context that is internal to and managed by a scheduler, or a context that was attached using a method other than the Scheduler::Attach or CurrentScheduler::Create methods, will result in an improper_scheduler_detach exception being thrown.
ПолучитьGet
Возвращает указатель на планировщик, связанный с контекстом вызова, который также называется текущим планировщиком.Returns a pointer to the scheduler associated with the calling context, also referred to as the current scheduler.
static Scheduler* __cdecl Get();
Возвращаемое значениеReturn Value
Указатель на планировщик, связанный с вызывающим контекстом (текущим планировщиком).A pointer to the scheduler associated with the calling context (the current scheduler).
КомментарииRemarks
В результате этого метода в процессе будет создан планировщик по умолчанию и/или присоединен к вызывающему контексту, если отсутствует планировщик, в данный момент связанный с вызывающим контекстом.This method will result in the process' default scheduler being created and/or attached to the calling context if there is no scheduler currently associated with the calling context. Дополнительные ссылки на Scheduler
объект, возвращаемый этим методом, не размещаются.No additional reference is placed on the Scheduler
object returned by this method.
жетнумберофвиртуалпроцессорсGetNumberOfVirtualProcessors
Возвращает текущее число виртуальных процессоров для планировщика, связанного с контекстом вызова.Returns the current number of virtual processors for the scheduler associated with the calling context.
static unsigned int __cdecl GetNumberOfVirtualProcessors();
Возвращаемое значениеReturn Value
Значение, если планировщик связан с контекстом вызова, текущим числом виртуальных процессоров для этого планировщика; в противном случае — значение -1
.If a scheduler is associated with the calling context, the current number of virtual processors for that scheduler; otherwise, the value -1
.
КомментарииRemarks
Этот метод не приведет к присоединению планировщика, если вызывающий контекст еще не связан с планировщиком.This method will not result in scheduler attachment if the calling context is not already associated with a scheduler.
Возвращаемое значение этого метода — это мгновенное выборка количества виртуальных процессоров для планировщика, связанного с вызывающим контекстом.The return value from this method is an instantaneous sampling of the number of virtual processors for the scheduler associated with the calling context. Это значение может быть устаревшим в момент возврата.This value can be stale the moment it is returned.
GetPolicyGetPolicy
Возвращает копию политики, с которой был создан текущий планировщик.Returns a copy of the policy that the current scheduler was created with.
static SchedulerPolicy __cdecl GetPolicy();
Возвращаемое значениеReturn Value
Копия политики, с которой был создан текущий планировщик.A copy of the policy that the current scheduler was created with.
КомментарииRemarks
В результате этого метода в процессе будет создан планировщик по умолчанию и/или присоединен к вызывающему контексту, если отсутствует планировщик, в данный момент связанный с вызывающим контекстом.This method will result in the process' default scheduler being created and/or attached to the calling context if there is no scheduler currently associated with the calling context.
УдостоверенияId
Возвращает уникальный идентификатор текущего планировщика.Returns a unique identifier for the current scheduler.
static unsigned int __cdecl Id();
Возвращаемое значениеReturn Value
Если планировщик связан с вызывающим контекстом, уникальный идентификатор для этого планировщика; в противном случае — значение -1
.If a scheduler is associated with the calling context, a unique identifier for that scheduler; otherwise, the value -1
.
КомментарииRemarks
Этот метод не приведет к присоединению планировщика, если вызывающий контекст еще не связан с планировщиком.This method will not result in scheduler attachment if the calling context is not already associated with a scheduler.
исаваилаблелокатионIsAvailableLocation
Определяет, доступно ли данное расположение в текущем планировщике.Determines whether a given location is available on the current scheduler.
static bool __cdecl IsAvailableLocation(const location& _Placement);
ПараметрыParameters
_Placement_Placement
Ссылка на расположение, о котором необходимо отправить запрос текущему планировщику.A reference to the location to query the current scheduler about.
Возвращаемое значениеReturn Value
Индикация доступности расположения, указанного параметром _Placement
, в текущем планировщике.An indication of whether or not the location specified by the _Placement
argument is available on the current scheduler.
КомментарииRemarks
Этот метод не приведет к присоединению планировщика, если вызывающий контекст еще не связан с планировщиком.This method will not result in scheduler attachment if the calling context is not already associated with a scheduler.
Обратите внимание, что возвращаемое значение является результатом проверки доступности указанного расположения в данный момент.Note that the return value is an instantaneous sampling of whether the given location is available. При наличии нескольких планировщиков динамическое управление ресурсами может добавлять или забирать ресурсы у планировщиков в любой момент.In the presence of multiple schedulers, dynamic resource management can add or take away resources from schedulers at any point. Если это произошло, доступность заданного расположения может измениться.Should this happen, the given location can change availability.
регистершутдовневентRegisterShutdownEvent
Приводит к тому, что дескриптор событий Windows, переданный в _ShutdownEvent
параметре, получает сигнал, когда планировщик, связанный с текущим контекстом, завершает работу и удаляет себя.Causes the Windows event handle passed in the _ShutdownEvent
parameter to be signaled when the scheduler associated with the current context shuts down and destroys itself. В момент получения сигнала о событии все запланированные работы планировщика завершены.At the time the event is signaled, all work that had been scheduled to the scheduler is complete. С помощью этого метода можно зарегистрировать несколько событий завершения работы.Multiple shutdown events can be registered through this method.
static void __cdecl RegisterShutdownEvent(HANDLE _ShutdownEvent);
ПараметрыParameters
_ShutdownEvent_ShutdownEvent
Дескриптор объекта события Windows, который будет оповещен среде выполнения, когда планировщик, связанный с текущим контекстом, завершает работу и удаляет себя.A handle to a Windows event object which will be signaled by the runtime when the scheduler associated with the current context shuts down and destroys itself.
КомментарииRemarks
При отсутствии планировщика, присоединенного к контексту вызова, вызов этого метода приведет к возникновению scheduler_not_attached исключения.If there is no scheduler attached to the calling context, calling this method will result in a scheduler_not_attached exception being thrown.
ScheduleTaskScheduleTask
Планирует задачу с невысокой плотностью в планировщике, связанном с вызывающим контекстом.Schedules a light-weight task within the scheduler associated with the calling context. Упрощенная задача будет размещена в группе расписаний, определенной средой выполнения.The light-weight task will be placed in a schedule group determined by the runtime. Версия, принимающая параметр _Placement
, склоняет задачу к выполнению в указанном расположении.The version that takes the parameter _Placement
causes the task to be biased towards executing at the specified location.
static void __cdecl ScheduleTask(
TaskProc _Proc,
_Inout_opt_ void* _Data);
static void __cdecl ScheduleTask(
TaskProc _Proc,
_Inout_opt_ void* _Data,
location& _Placement);
ПараметрыParameters
_Proc_Proc
Указатель на функцию, которая должна быть выполнена, чтобы выполнить задачу неплотности.A pointer to the function to execute to perform the body of the light-weight task.
_Data_Data
Указатель типа void на данные, которые будут переданы в качестве параметра в текст задачи.A void pointer to the data that will be passed as a parameter to the body of the task.
_Placement_Placement
Ссылка на расположение, где будет склонна выполняться упрощенная задача.A reference to a location where the light-weight task will be biased towards executing at.
КомментарииRemarks
В результате этого метода в процессе будет создан планировщик по умолчанию и/или присоединен к вызывающему контексту, если отсутствует планировщик, в данный момент связанный с вызывающим контекстом.This method will result in the process' default scheduler being created and/or attached to the calling context if there is no scheduler currently associated with the calling context.
См. также разделSee also
Пространство имен Concurrencyconcurrency Namespace
Класс SchedulerScheduler Class
полициелементкэйPolicyElementKey
Планировщик заданийTask Scheduler