global_control¶
[scheduler.global_control]
Use this class to control certain settings or behavior of the oneAPI Threading Building Blocks dynamic library.
An object of class global_control
, or a “control variable”, affects one of several behavioral aspects, or parameters, of TBB.
Class global_control
is primarily intended for use at the application level, to control the whole application behavior.
The current set of parameters that you can modify is defined by global_control::parameter
enumeration.
The parameter and the value it should take are specified as arguments to the constructor of a control variable.
The impact of the control variable ends when its lifetime is complete.
Control variables can be created in different threads, and may have nested or overlapping scopes. However, at any point in time each controlled parameter has a single active value that applies to the whole process. This value is selected from all currently existing control variables by applying a parameter-specific selection rule.
// Defined in header <tbb/global_control.h>
namespace tbb {
class global_control {
public:
enum parameter {
max_allowed_parallelism,
thread_stack_size
};
global_control(parameter p, size_t value);
~global_control();
static size_t active_value(parameter param);
};
} // namespace tbb
Member types and constants¶
-
enum
parameter
::
max_allowed_parallelism
¶ Selection rule: minimum
Limit total number of worker threads that can be active in the task scheduler to
parameter_value - 1
.Note
With
max_allowed_parallelism
set to1
,global_control
enforces serial execution of all tasks by the application thread(s), i.e. the task scheduler does not allow worker threads to run. There is one exception: if some work is submitted for execution viatask_arena::enqueue
, a single worker thread will still run ignoring themax_allowed_parallelism
restriction.
-
enum
parameter
::
thread_stack_size
¶ Selection rule: maximum
Set stack size for threads created by the library, including working threads in the task scheduler and threads controlled by thread wrapper classes.
Member functions¶
-
global_control
(parameter param, size_t value)¶ Constructs a
global_control
object with a specified control parameter and it’s value.
-
~global_control
()¶ Destructs a control variable object and ends it’s impact.
-
static size_t
active_value
(parameter param)¶ Returns the currently active value of the setting defined by
param
.
See also: