Intel(R) Threading Building Blocks Doxygen Documentation  version 4.2.3
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_controlmy_next
 
parameter my_param
 

Detailed Description

Definition at line 25 of file global_control.h.

Member Enumeration Documentation

◆ parameter

Enumerator
max_allowed_parallelism 
thread_stack_size 
parameter_max 

Definition at line 27 of file global_control.h.

27  {
30  parameter_max // insert new parameters above this point
31  };

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.

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

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.

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

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)
staticprivate

Definition at line 580 of file tbb_main.cpp.

580  {
582  return controls[param]->active_value();
583 }

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)
inlinestatic

Definition at line 59 of file global_control.h.

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

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 524 of file tbb_main.cpp.

524  {
526  control_storage *const c = controls[my_param];
527 
531  // to guarantee that apply_active() is called with current active value,
532  // calls it here and in internal_destroy() under my_list_mutex
533  c->apply_active();
534  }
535  my_next = c->my_head;
536  // publish my_head, at this point my_active_value must be valid
537  c->my_head = this;
538 }

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 540 of file tbb_main.cpp.

540  {
541  global_control *prev = 0;
542 
544  control_storage *const c = controls[my_param];
545  __TBB_ASSERT( c->my_head, NULL );
546 
547  // Concurrent reading and changing global parameter is possible.
548  // In this case, my_active_value may not match current state of parameters.
549  // This is OK because:
550  // 1) my_active_value is either current or previous
551  // 2) my_active_value is current on internal_destroy leave
553  size_t new_active = (size_t)-1, old_active = c->my_active_value;
554 
555  if ( c->my_head != this )
556  new_active = c->my_head->my_value;
557  else if ( c->my_head->my_next )
558  new_active = c->my_head->my_next->my_value;
559  // if there is only one element, new_active will be set later
560  for ( global_control *curr = c->my_head; curr; prev = curr, curr = curr->my_next )
561  if ( curr == this ) {
562  if ( prev )
563  prev->my_next = my_next;
564  else
565  c->my_head = my_next;
566  } else
567  if (c->is_first_arg_preferred(curr->my_value, new_active))
568  new_active = curr->my_value;
569 
570  if ( !c->my_head ) {
571  __TBB_ASSERT( new_active==(size_t)-1, NULL );
572  new_active = c->default_value();
573  }
574  if ( new_active != old_active ) {
575  c->my_active_value = new_active;
576  c->apply_active();
577  }
578 }

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:
tbb::interface9::global_control::active_value
static size_t active_value(parameter p)
Definition: global_control.h:59
tbb::interface9::global_control::parameter_max
Definition: global_control.h:30
__TBB_ASSERT_RELEASE
#define __TBB_ASSERT_RELEASE(predicate, message)
Definition: tbb_stddef.h:134
tbb::interface9::global_control::my_value
size_t my_value
Definition: global_control.h:64
__TBB_ASSERT
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
tbb::interface9::global_control::my_next
global_control * my_next
Definition: global_control.h:65
p
void const char const char int ITT_FORMAT __itt_group_sync p
Definition: ittnotify_static.h:76
tbb::internal::control_storage::my_list_mutex
spin_mutex my_list_mutex
Definition: tbb_main.cpp:455
tbb::internal::control_storage::apply_active
virtual void apply_active() const
Definition: tbb_main.cpp:458
tbb::internal::control_storage::default_value
virtual size_t default_value() const =0
tbb::internal::control_storage
Definition: tbb_main.cpp:450
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:177
tbb::interface9::global_control::internal_destroy
void __TBB_EXPORTED_METHOD internal_destroy()
Definition: tbb_main.cpp:540
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:106
tbb::internal::control_storage::my_active_value
size_t my_active_value
Definition: tbb_main.cpp:453
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:459
tbb::internal::controls
static control_storage * controls[]
Definition: tbb_main.cpp:511
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::interface9::global_control::internal_create
void __TBB_EXPORTED_METHOD internal_create()
Definition: tbb_main.cpp:524
tbb::spin_mutex::scoped_lock
friend class scoped_lock
Definition: spin_mutex.h:179
tbb::internal::control_storage::active_value
virtual size_t active_value() const
Definition: tbb_main.cpp:462
tbb::interface9::global_control::thread_stack_size
Definition: global_control.h:29
tbb::interface9::global_control::global_control
global_control(parameter p, size_t value)
Definition: global_control.h:33
tbb::internal::control_storage::my_head
atomic< global_control * > my_head
Definition: tbb_main.cpp:454

Copyright © 2005-2019 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.