tbb::internal::rml::private_server Class Reference
Inheritance diagram for tbb::internal::rml::private_server:
Collaboration diagram for tbb::internal::rml::private_server:

## Public Member Functions

| private_server (tbb_client &client)
version_type | version () const __TBB_override
void | request_close_connection (bool) __TBB_override
void | yield () __TBB_override
void | independent_thread_number_changed (int) __TBB_override
unsigned | default_concurrency () const __TBB_override
void | adjust_job_count_estimate (int delta) __TBB_override

## Private Types

typedef scheduler_mutex_type | asleep_list_mutex_type
| Protects my_asleep_list_root. More...

## Private Member Functions

void | propagate_chain_reaction ()
| Wake up to two sleeping workers, if there are any sleeping. More...
bool | try_insert_in_asleep_list (private_worker &t)
| Try to add t to list of sleeping workers. More...
void | wake_some (int additional_slack)
| Equivalent of adding additional_slack to my_slack and waking up to 2 threads if my_slack permits. More...
virtual | ~private_server ()
void | remove_server_ref ()
Private Member Functions inherited from tbb::internal::no_copy
| no_copy (const no_copy &)=delete
| no_copy ()=default

## Private Attributes

tbb_client & | my_client
const tbb_client::size_type | my_n_thread
| Maximum number of threads to be created. More...
const size_t | my_stack_size
| Stack size for each thread. *‍/. More...
atomic< int > | my_slack
| Number of jobs that could use their associated thread minus number of active threads. More...
atomic< int > | my_ref_count
| Counter used to determine when to delete this. More...
padded_private_worker * | my_thread_array
tbb::atomic< private_worker * > | my_asleep_list_root
| List of workers that are asleep or committed to sleeping until notified by another thread. More...
asleep_list_mutex_type | my_asleep_list_mutex

## Friends

class | private_worker

## Detailed Description

Definition at line 118 of file private_server.cpp.

## Member Typedef Documentation

## asleep_list_mutex_type

typedef scheduler_mutex_type tbb::internal::rml::private_server::asleep_list_mutex_type

private

Protects my_asleep_list_root.

Definition at line 144 of file private_server.cpp.

## Constructor & Destructor Documentation

## ~private_server()

tbb::internal::rml::private_server::~private_server | ( |  | ) |

private virtual

Definition at line 339 of file private_server.cpp.

{
__TBB_ASSERT( my_net_slack_requests==0, NULL );
for( size_t i=my_n_thread; i--; )
my_thread_array[i].~padded_private_worker();
tbb::cache_aligned_allocator<padded_private_worker>().deallocate( my_thread_array, my_n_thread );
tbb::internal::poison_pointer( my_thread_array );
}
__TBB_ASSERT
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
tbb::internal::poison_pointer
void poison_pointer(T *__TBB_atomic &)
Definition: tbb_stddef.h:305
tbb::cache_aligned_allocator
Meets "allocator" requirements of ISO C++ Standard, Section 20.1.5.
Definition: cache_aligned_allocator.h:60
tbb::cache_aligned_allocator::deallocate
void deallocate(pointer p, size_type)
Free block of memory that starts on a cache line.
Definition: cache_aligned_allocator.h:86
tbb::internal::rml::private_server::my_n_thread
const tbb_client::size_type my_n_thread
Maximum number of threads to be created.
Definition: private_server.cpp:123
tbb::internal::rml::private_server::my_thread_array
padded_private_worker * my_thread_array
Definition: private_server.cpp:138

References __TBB_ASSERT, tbb::cache_aligned_allocator< T >::deallocate(), my_n_thread, my_thread_array, and tbb::internal::poison_pointer().

Referenced by remove_server_ref().

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

## private_server()

tbb::internal::rml::private_server::private_server | ( | tbb_client & | client | ) |

Definition at line 319 of file private_server.cpp.

:
my_client(client),
my_n_thread(client.max_job_count()),
my_stack_size(client.min_stack_size()),
my_thread_array(NULL)
{
my_ref_count = my_n_thread+1;
my_slack = 0;
#if TBB_USE_ASSERT
my_net_slack_requests = 0;
#endif /* TBB_USE_ASSERT */
my_asleep_list_root = NULL;
my_thread_array = tbb::cache_aligned_allocator<padded_private_worker>().allocate( my_n_thread );
for( size_t i=0; i<my_n_thread; ++i ) {
private_worker* t = new( &my_thread_array[i] ) padded_private_worker( *this, client, i );
t->my_next = my_asleep_list_root;
my_asleep_list_root = t;
}
}
tbb::cache_aligned_allocator::allocate
pointer allocate(size_type n, const void *hint=0)
Allocate space for n objects, starting on a cache/sector line.
Definition: cache_aligned_allocator.h:80
tbb::internal::rml::private_server::my_stack_size
const size_t my_stack_size
Stack size for each thread. *‍/.
Definition: private_server.cpp:126
tbb::internal::rml::private_server::my_ref_count
atomic< int > my_ref_count
Counter used to determine when to delete this.
Definition: private_server.cpp:136
tbb::internal::rml::private_server::my_slack
atomic< int > my_slack
Number of jobs that could use their associated thread minus number of active threads.
Definition: private_server.cpp:133
tbb::internal::rml::private_server::my_asleep_list_root
tbb::atomic< private_worker * > my_asleep_list_root
List of workers that are asleep or committed to sleeping until notified by another thread.
Definition: private_server.cpp:141
tbb::internal::rml::private_server::private_worker
friend class private_worker
Definition: private_server.cpp:176
tbb::internal::rml::private_server::my_client
tbb_client & my_client
Definition: private_server.cpp:120

References tbb::cache_aligned_allocator< T >::allocate(), my_asleep_list_root, my_n_thread, tbb::internal::rml::private_worker::my_next, my_ref_count, my_slack, and my_thread_array.

Here is the call graph for this function:

## Member Function Documentation

## adjust_job_count_estimate()

void tbb::internal::rml::private_server::adjust_job_count_estimate | ( | int | delta | ) |

Definition at line 399 of file private_server.cpp.

{
#if TBB_USE_ASSERT
my_net_slack_requests+=delta;
#endif /* TBB_USE_ASSERT */
if( delta<0 ) {
my_slack+=delta;
} else if( delta>0 ) {
wake_some( delta );
}
}
tbb::internal::rml::private_server::wake_some
void wake_some(int additional_slack)
Equivalent of adding additional_slack to my_slack and waking up to 2 threads if my_slack permits.
Definition: private_server.cpp:364

References my_slack, and wake_some().

Here is the call graph for this function:

## default_concurrency()

unsigned tbb::internal::rml::private_server::default_concurrency | ( |  | ) | const

inline

Definition at line 194 of file private_server.cpp.

{ return governor::default_num_threads() - 1; }
tbb::internal::governor::default_num_threads
static unsigned default_num_threads()
Definition: governor.h:84

References tbb::internal::governor::default_num_threads().

Here is the call graph for this function:

## independent_thread_number_changed()

void tbb::internal::rml::private_server::independent_thread_number_changed | ( | int |  | ) |

inline

Definition at line 192 of file private_server.cpp.

{__TBB_ASSERT(false,NULL);}

References __TBB_ASSERT.

## propagate_chain_reaction()

void tbb::internal::rml::private_server::propagate_chain_reaction | ( |  | ) |

inline private

Wake up to two sleeping workers, if there are any sleeping.

The call is used to propagate a chain reaction where each thread wakes up two threads, which in turn each wake up two threads, etc.

Definition at line 154 of file private_server.cpp.

{
// First test of a double-check idiom. Second test is inside wake_some(0).
if( my_asleep_list_root )
wake_some(0);
}

References my_asleep_list_root, and wake_some().

Referenced by tbb::internal::rml::private_worker::run().

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

## remove_server_ref()

void tbb::internal::rml::private_server::remove_server_ref | ( |  | ) |

inline private

Definition at line 168 of file private_server.cpp.

{
if( --my_ref_count==0 ) {
my_client.acknowledge_close_connection();
this->~private_server();
tbb::cache_aligned_allocator<private_server>().deallocate( this, 1 );
}
}
tbb::internal::rml::private_server::~private_server
virtual ~private_server()
Definition: private_server.cpp:339

References tbb::cache_aligned_allocator< T >::deallocate(), my_client, my_ref_count, and ~private_server().

Referenced by request_close_connection(), tbb::internal::rml::private_worker::run(), and tbb::internal::rml::private_worker::start_shutdown().

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

## request_close_connection()

void tbb::internal::rml::private_server::request_close_connection | ( | bool |  | ) |

inline

Definition at line 184 of file private_server.cpp.

{
for( size_t i=0; i<my_n_thread; ++i )
my_thread_array[i].start_shutdown();
remove_server_ref();
}
tbb::internal::rml::private_server::remove_server_ref
void remove_server_ref()
Definition: private_server.cpp:168

References my_n_thread, my_thread_array, and remove_server_ref().

Here is the call graph for this function:

## try_insert_in_asleep_list()

bool tbb::internal::rml::private_server::try_insert_in_asleep_list | ( | private_worker & | t | ) |

inline private

Try to add t to list of sleeping workers.

Definition at line 347 of file private_server.cpp.

{
asleep_list_mutex_type::scoped_lock lock;
if( !lock.try_acquire(my_asleep_list_mutex) )
return false;
// Contribute to slack under lock so that if another takes that unit of slack,
// it sees us sleeping on the list and wakes us up.
int k = ++my_slack;
if( k<=0 ) {
t.my_next = my_asleep_list_root;
my_asleep_list_root = &t;
return true;
} else {
--my_slack;
return false;
}
}
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::rml::private_server::my_asleep_list_mutex
asleep_list_mutex_type my_asleep_list_mutex
Definition: private_server.cpp:145

References lock, my_asleep_list_mutex, my_asleep_list_root, tbb::internal::rml::private_worker::my_next, and my_slack.

Referenced by tbb::internal::rml::private_worker::run().

Here is the caller graph for this function:

## version()

version_type tbb::internal::rml::private_server::version | ( |  | ) | const

inline

Definition at line 180 of file private_server.cpp.

{
return 0;
}

## wake_some()

void tbb::internal::rml::private_server::wake_some | ( | int | additional_slack | ) |

private

Equivalent of adding additional_slack to my_slack and waking up to 2 threads if my_slack permits.

Definition at line 364 of file private_server.cpp.

{
__TBB_ASSERT( additional_slack>=0, NULL );
private_worker* wakee[2];
private_worker**w = wakee;
{
asleep_list_mutex_type::scoped_lock lock(my_asleep_list_mutex);
while( my_asleep_list_root && w<wakee+2 ) {
if( additional_slack>0 ) {
if (additional_slack+my_slack<=0) // additional demand does not exceed surplus supply
break;
--additional_slack;
} else {
// Chain reaction; Try to claim unit of slack
int old;
do {
old = my_slack;
if( old<=0 ) goto done;
} while( my_slack.compare_and_swap(old-1,old)!=old );
}
// Pop sleeping worker to combine with claimed unit of slack
my_asleep_list_root = (*w++ = my_asleep_list_root)->my_next;
}
if( additional_slack ) {
// Contribute our unused slack to my_slack.
my_slack += additional_slack;
}
}
done:
while( w>wakee ) {
private_worker* ww = *--w;
ww->my_next = NULL;
ww->wake_or_launch();
}
}

References __TBB_ASSERT, lock, my_asleep_list_mutex, my_asleep_list_root, tbb::internal::rml::private_worker::my_next, my_slack, and tbb::internal::rml::private_worker::wake_or_launch().

Referenced by adjust_job_count_estimate(), and propagate_chain_reaction().

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

## yield()

void tbb::internal::rml::private_server::yield | ( |  | ) |

inline

Definition at line 190 of file private_server.cpp.

{__TBB_Yield();}
__TBB_Yield
#define __TBB_Yield()
Definition: ibm_aix51.h:44

References __TBB_Yield.

## Friends And Related Function Documentation

## private_worker

friend class private_worker

friend

Definition at line 176 of file private_server.cpp.

## Member Data Documentation

## my_asleep_list_mutex

asleep_list_mutex_type tbb::internal::rml::private_server::my_asleep_list_mutex

private

Definition at line 145 of file private_server.cpp.

Referenced by try_insert_in_asleep_list(), and wake_some().

## my_asleep_list_root

tbb::atomic<private_worker*> tbb::internal::rml::private_server::my_asleep_list_root

private

List of workers that are asleep or committed to sleeping until notified by another thread.

Definition at line 141 of file private_server.cpp.

Referenced by private_server(), propagate_chain_reaction(), try_insert_in_asleep_list(), and wake_some().

## my_client

tbb_client& tbb::internal::rml::private_server::my_client

private

Definition at line 120 of file private_server.cpp.

Referenced by remove_server_ref().

## my_n_thread

const tbb_client::size_type tbb::internal::rml::private_server::my_n_thread

private

Maximum number of threads to be created.

Threads are created lazily, so maximum might not actually be reached.

Definition at line 123 of file private_server.cpp.

Referenced by private_server(), request_close_connection(), and ~private_server().

## my_ref_count

atomic<int> tbb::internal::rml::private_server::my_ref_count

private

Counter used to determine when to delete this.

Definition at line 136 of file private_server.cpp.

Referenced by private_server(), and remove_server_ref().

## my_slack

atomic<int> tbb::internal::rml::private_server::my_slack

private

Number of jobs that could use their associated thread minus number of active threads.

If negative, indicates oversubscription. If positive, indicates that more threads should run. Can be lowered asynchronously, but must be raised only while holding my_asleep_list_mutex, because raising it impacts the invariant for sleeping threads.

Definition at line 133 of file private_server.cpp.

Referenced by adjust_job_count_estimate(), private_server(), tbb::internal::rml::private_worker::run(), try_insert_in_asleep_list(), and wake_some().

## my_stack_size

const size_t tbb::internal::rml::private_server::my_stack_size

private

Stack size for each thread. *‍/.

Definition at line 126 of file private_server.cpp.

Referenced by tbb::internal::rml::private_worker::wake_or_launch().

## my_thread_array

padded_private_worker* tbb::internal::rml::private_server::my_thread_array

private

Definition at line 138 of file private_server.cpp.

Referenced by private_server(), request_close_connection(), and ~private_server().

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

- private_server.cpp

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.