SchedulerPolicy Class

The SchedulerPolicy class contains a set of key/value pairs, one for each policy element, that control the behavior of a scheduler instance.

Syntax

class SchedulerPolicy;

Members

Public Constructors

Name Description
SchedulerPolicy Overloaded. Constructs a new scheduler policy and populates it with values for policy keys supported by Concurrency Runtime schedulers and the Resource Manager.
~SchedulerPolicy Destructor Destroys a scheduler policy.

Public Methods

Name Description
GetPolicyValue Retrieves the value of the policy key supplied as the key parameter.
SetConcurrencyLimits Simultaneously sets the MinConcurrency and MaxConcurrency policies on the SchedulerPolicy object.
SetPolicyValue Sets the value of the policy key supplied as the key parameter and returns the old value.

Public Operators

Name Description
operator= Assigns the scheduler policy from another scheduler policy.

Remarks

For more information about the policies which can be controlled using the SchedulerPolicy class, see PolicyElementKey.

Inheritance Hierarchy

SchedulerPolicy

Requirements

Header: concrt.h, concrtrm.h

Namespace: concurrency

GetPolicyValue

Retrieves the value of the policy key supplied as the key parameter.

unsigned int GetPolicyValue(PolicyElementKey key) const;

Parameters

key
The policy key to retrieve a value for.

Return Value

If the key specified by the key parameter is supported, the policy value for the key cast to an unsigned int.

Remarks

The method will throw invalid_scheduler_policy_key for an invalid policy key.

operator=

Assigns the scheduler policy from another scheduler policy.

SchedulerPolicy& operator= (const SchedulerPolicy& _RhsPolicy);

Parameters

_RhsPolicy
The policy to assign to this policy.

Return Value

A reference to the scheduler policy.

Remarks

Often, the most convenient way to define a new scheduler policy is to copy an existing policy and modify it using the SetPolicyValue or SetConcurrencyLimits methods.

SchedulerPolicy

Constructs a new scheduler policy and populates it with values for policy keys supported by Concurrency Runtime schedulers and the Resource Manager.

SchedulerPolicy();

SchedulerPolicy(
    size_t _PolicyKeyCount,
...);

SchedulerPolicy(
    const SchedulerPolicy& _SrcPolicy);

Parameters

_PolicyKeyCount
The number of key/value pairs that follow the _PolicyKeyCount parameter.

_SrcPolicy
The source policy to copy.

Remarks

The first constructor creates a new scheduler policy where all policies will be initialized to their default values.

The second constructor creates a new scheduler policy that uses a named-parameter style of initialization. Values after the _PolicyKeyCount parameter are supplied as key/value pairs. Any policy key which is not specified in this constructor will have its default value. This constructor could throw the exceptions invalid_scheduler_policy_key, invalid_scheduler_policy_value or invalid_scheduler_policy_thread_specification.

The third constructor is a copy constructor. Often, the most convenient way to define a new scheduler policy is to copy an existing policy and modify it using the SetPolicyValue or SetConcurrencyLimits methods.

~SchedulerPolicy

Destroys a scheduler policy.

~SchedulerPolicy();

SetConcurrencyLimits

Simultaneously sets the MinConcurrency and MaxConcurrency policies on the SchedulerPolicy object.

void SetConcurrencyLimits(
    unsigned int _MinConcurrency,
    unsigned int _MaxConcurrency = MaxExecutionResources);

Parameters

_MinConcurrency
The value for the MinConcurrency policy key.

_MaxConcurrency
The value for the MaxConcurrency policy key.

Remarks

The method will throw invalid_scheduler_policy_thread_specification if the value specified for the MinConcurrency policy is greater than that specified for the MaxConcurrency policy.

The method can also throw invalid_scheduler_policy_value for other invalid values.

SetPolicyValue

Sets the value of the policy key supplied as the key parameter and returns the old value.

unsigned int SetPolicyValue(
    PolicyElementKey key,
    unsigned int value);

Parameters

key
The policy key to set a value for.

value
The value to set the policy key to.

Return Value

If the key specified by the key parameter is supported, the old policy value for the key cast to an unsigned int.

Remarks

The method will throw invalid_scheduler_policy_key for an invalid policy key or any policy key whose value cannot be set by the SetPolicyValue method.

The method will throw invalid_scheduler_policy_value for a value that is not supported for the key specified by the key parameter.

Note that this method is not allowed to set the MinConcurrency or MaxConcurrency policies. To set these values, use the SetConcurrencyLimits method.

See also

concurrency Namespace
PolicyElementKey
CurrentScheduler Class
Scheduler Class
Task Scheduler