tbb::interface9::global_control Class Reference

`#include <global_control.h>`

Collaboration diagram for tbb::interface9::global_control:

## Public Types

enum | parameter { max_allowed_parallelism, thread_stack_size, parameter_max }

## Public Member Functions

| global_control (parameter p, size_t value)
| ~global_control ()

## Static Public Member Functions

static size_t | active_value (parameter p)

## Private Member Functions

void __TBB_EXPORTED_METHOD | internal_create ()
void __TBB_EXPORTED_METHOD | internal_destroy ()

## Static Private Member Functions

static size_t __TBB_EXPORTED_FUNC | active_value (int param)

## Private Attributes

size_t | my_value
global_control * | my_next
parameter | my_param

## Detailed Description

Definition at line 25 of file global_control.h.

## Member Enumeration Documentation

## parameter

enum tbb::interface9::global_control::parameter

Enumerator
max_allowed_parallelism |
thread_stack_size |
parameter_max |

Definition at line 27 of file global_control.h.

{
max_allowed_parallelism,
thread_stack_size,
parameter_max // insert new parameters above this point
};

## Constructor & Destructor Documentation

## global_control()

tbb::interface9::global_control::global_control | ( | parameter | p,
|  | size_t | value
| ) |  |

inline

Definition at line 33 of file global_control.h.

:
my_value(value), my_next(NULL), my_param(p) {
__TBB_ASSERT(my_param < parameter_max, "Invalid parameter");
#if __TBB_WIN8UI_SUPPORT && (_WIN32_WINNT < 0x0A00)
// For Windows 8 Store* apps it's impossible to set stack size
if (p==thread_stack_size)
return;
#elif __TBB_x86_64 && (_WIN32 || _WIN64)
if (p==thread_stack_size)
__TBB_ASSERT_RELEASE((unsigned)value == value, "Stack size is limited to unsigned int range");
#endif
if (my_param==max_allowed_parallelism)
__TBB_ASSERT_RELEASE(my_value>0, "max_allowed_parallelism cannot be 0.");
internal_create();
}

References __TBB_ASSERT, __TBB_ASSERT_RELEASE, internal_create(), max_allowed_parallelism, my_param, my_value, p, parameter_max, thread_stack_size, and value.

Here is the call graph for this function:

## ~global_control()

tbb::interface9::global_control::~global_control | ( |  | ) |

inline

Definition at line 49 of file global_control.h.

{
__TBB_ASSERT(my_param < parameter_max, "Invalid parameter. Probably the object was corrupted.");
#if __TBB_WIN8UI_SUPPORT && (_WIN32_WINNT < 0x0A00)
// For Windows 8 Store* apps it's impossible to set stack size
if (my_param==thread_stack_size)
return;
#endif
internal_destroy();
}

References __TBB_ASSERT, internal_destroy(), my_param, parameter_max, and thread_stack_size.

Here is the call graph for this function:

## Member Function Documentation

## active_value() [1/2]

size_t tbb::interface9::global_control::active_value | ( | int | param | ) |

static private

Definition at line 579 of file tbb_main.cpp.

{
__TBB_ASSERT_RELEASE( param < global_control::parameter_max, NULL );
return controls[param]->active_value();
}

References __TBB_ASSERT_RELEASE, tbb::internal::control_storage::active_value(), tbb::internal::controls, and parameter_max.

Here is the call graph for this function:

## active_value() [2/2]

static size_t tbb::interface9::global_control::active_value | ( | parameter | p | ) |

inline static

Definition at line 59 of file global_control.h.

{
__TBB_ASSERT(p < parameter_max, "Invalid parameter");
return active_value((int)p);
}

References __TBB_ASSERT, p, and parameter_max.

Referenced by tbb::internal::market::global_market(), and tbb::internal::tbb_thread_v3::internal_start().

Here is the caller graph for this function:

## internal_create()

void tbb::interface9::global_control::internal_create | ( |  | ) |

private

Definition at line 523 of file tbb_main.cpp.

{
__TBB_ASSERT_RELEASE( my_param < global_control::parameter_max, NULL );
control_storage *const c = controls[my_param];
spin_mutex::scoped_lock lock(c->my_list_mutex);
if (!c->my_head || c->is_first_arg_preferred(my_value, c->my_active_value)) {
c->my_active_value = my_value;
// to guarantee that apply_active() is called with current active value,
// calls it here and in internal_destroy() under my_list_mutex
c->apply_active();
}
my_next = c->my_head;
// publish my_head, at this point my_active_value must be valid
c->my_head = this;
}

References __TBB_ASSERT_RELEASE, tbb::internal::control_storage::apply_active(), tbb::internal::controls, tbb::internal::control_storage::is_first_arg_preferred(), lock, tbb::internal::control_storage::my_active_value, tbb::internal::control_storage::my_head, tbb::internal::control_storage::my_list_mutex, and parameter_max.

Referenced by global_control().

Here is the call graph for this function:
Here is the caller graph for this function:

## internal_destroy()

void tbb::interface9::global_control::internal_destroy | ( |  | ) |

private

Definition at line 539 of file tbb_main.cpp.

{
global_control *prev = 0;
__TBB_ASSERT_RELEASE( my_param < global_control::parameter_max, NULL );
control_storage *const c = controls[my_param];
__TBB_ASSERT( c->my_head, NULL );
// Concurrent reading and changing global parameter is possible.
// In this case, my_active_value may not match current state of parameters.
// This is OK because:
// 1) my_active_value is either current or previous
// 2) my_active_value is current on internal_destroy leave
spin_mutex::scoped_lock lock(c->my_list_mutex);
size_t new_active = (size_t)-1, old_active = c->my_active_value;
if ( c->my_head != this )
new_active = c->my_head->my_value;
else if ( c->my_head->my_next )
new_active = c->my_head->my_next->my_value;
// if there is only one element, new_active will be set later
for ( global_control *curr = c->my_head; curr; prev = curr, curr = curr->my_next )
if ( curr == this ) {
if ( prev )
prev->my_next = my_next;
else
c->my_head = my_next;
} else
if (c->is_first_arg_preferred(curr->my_value, new_active))
new_active = curr->my_value;
if ( !c->my_head ) {
__TBB_ASSERT( new_active==(size_t)-1, NULL );
new_active = c->default_value();
}
if ( new_active != old_active ) {
c->my_active_value = new_active;
c->apply_active();
}
}

References __TBB_ASSERT, __TBB_ASSERT_RELEASE, tbb::internal::control_storage::apply_active(), tbb::internal::controls, tbb::internal::control_storage::default_value(), tbb::internal::control_storage::is_first_arg_preferred(), lock, tbb::internal::control_storage::my_active_value, tbb::internal::control_storage::my_head, tbb::internal::control_storage::my_list_mutex, my_next, and parameter_max.

Referenced by ~global_control().

Here is the call graph for this function:
Here is the caller graph for this function:

## Member Data Documentation

## my_next

global_control* tbb::interface9::global_control::my_next

private

Definition at line 65 of file global_control.h.

Referenced by internal_destroy().

## my_param

parameter tbb::interface9::global_control::my_param

private

Definition at line 66 of file global_control.h.

Referenced by global_control(), and ~global_control().

## my_value

size_t tbb::interface9::global_control::my_value

private

Definition at line 64 of file global_control.h.

Referenced by global_control().

The documentation for this class was generated from the following files:

- global_control.h
- tbb_main.cpp

tbb::internal::control_storage::my_active_value
size_t my_active_value
Definition: tbb_main.cpp:452
__TBB_ASSERT_RELEASE
#define __TBB_ASSERT_RELEASE(predicate, message)
Definition: tbb_stddef.h:134
tbb::interface9::global_control::thread_stack_size
Definition: global_control.h:29
__TBB_ASSERT
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
tbb::internal::control_storage
Definition: tbb_main.cpp:449
tbb::interface9::global_control::parameter_max
Definition: global_control.h:30
tbb::interface9::global_control::global_control
global_control(parameter p, size_t value)
Definition: global_control.h:33
tbb::internal::control_storage::is_first_arg_preferred
virtual bool is_first_arg_preferred(size_t a, size_t b) const
Definition: tbb_main.cpp:458
tbb::internal::controls
static control_storage * controls[]
Definition: tbb_main.cpp:510
tbb::spin_mutex::scoped_lock
friend class scoped_lock
Definition: spin_mutex.h:179
tbb::interface9::global_control::active_value
static size_t active_value(parameter p)
Definition: global_control.h:59
tbb::interface9::global_control::my_next
global_control * my_next
Definition: global_control.h:65
tbb::internal::control_storage::active_value
virtual size_t active_value() const
Definition: tbb_main.cpp:461
lock
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void * lock
Definition: ittnotify_static.h:121
tbb::internal::control_storage::my_head
atomic< global_control * > my_head
Definition: tbb_main.cpp:453
tbb::interface9::global_control::internal_create
void __TBB_EXPORTED_METHOD internal_create()
Definition: tbb_main.cpp:523
tbb::interface9::global_control::internal_destroy
void __TBB_EXPORTED_METHOD internal_destroy()
Definition: tbb_main.cpp:539
value
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long value
Definition: ittnotify_static.h:192
tbb::internal::control_storage::my_list_mutex
spin_mutex my_list_mutex
Definition: tbb_main.cpp:454
tbb::internal::control_storage::apply_active
virtual void apply_active() const
Definition: tbb_main.cpp:457
tbb::interface9::global_control::my_value
size_t my_value
Definition: global_control.h:64
p
void const char const char int ITT_FORMAT __itt_group_sync p
Definition: ittnotify_static.h:91
tbb::interface9::global_control::max_allowed_parallelism
Definition: global_control.h:28
tbb::interface9::global_control::my_param
parameter my_param
Definition: global_control.h:66
tbb::internal::control_storage::default_value
virtual size_t default_value() const =0

Copyright © 2005-2020 Intel Corporation. All Rights Reserved.

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.