tbb::interface6::aggregator_ext< handler_type > Class Template Reference

Aggregator base class and expert interface. More...

`#include <aggregator.h>`

Inheritance diagram for tbb::interface6::aggregator_ext< handler_type >:
Collaboration diagram for tbb::interface6::aggregator_ext< handler_type >:

## Public Member Functions

| aggregator_ext (const handler_type &h)
void | process (aggregator_operation *op)
| EXPERT INTERFACE: Enter a user-made operation into the aggregator's mailbox. More...

## Protected Member Functions

void | execute_impl (aggregator_operation &op)

## Private Member Functions

void | start_handle_operations ()
| Trigger the handling of operations when the handler is free. More...
Private Member Functions inherited from tbb::internal::no_copy
| no_copy (const no_copy &)=delete
| no_copy ()=default

## Private Attributes

atomic< aggregator_operation * > | mailbox
| An atomically updated list (aka mailbox) of aggregator_operations. More...
uintptr_t | handler_busy
| Controls thread access to handle_operations. More...
handler_type | handle_operations

## Detailed Description

### template<typename handler_type>
class tbb::interface6::aggregator_ext< handler_type >

Aggregator base class and expert interface.

An aggregator for collecting operations coming from multiple sources and executing them serially on a single thread.

Definition at line 96 of file aggregator.h.

## Constructor & Destructor Documentation

## aggregator_ext()

template<typename handler_type >

tbb::interface6::aggregator_ext< handler_type >::aggregator_ext | ( | const handler_type & | h | ) |

inline

Definition at line 98 of file aggregator.h.

: handler_busy(0), handle_operations(h) { mailbox = NULL; }
h
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 h
Definition: ittnotify_static.h:159
tbb::interface6::aggregator_ext::handle_operations
handler_type handle_operations
Definition: aggregator.h:145
tbb::interface6::aggregator_ext::mailbox
atomic< aggregator_operation * > mailbox
An atomically updated list (aka mailbox) of aggregator_operations.
Definition: aggregator.h:139
tbb::interface6::aggregator_ext::handler_busy
uintptr_t handler_busy
Controls thread access to handle_operations.
Definition: aggregator.h:143

## Member Function Documentation

## execute_impl()

template<typename handler_type >

void tbb::interface6::aggregator_ext< handler_type >::execute_impl | ( | aggregator_operation & | op | ) |

inline protected

Place operation in mailbox, then either handle mailbox or wait for the operation to be completed by a different thread.

Definition at line 107 of file aggregator.h.

{
aggregator_operation* res;
// ITT note: &(op.status) tag is used to cover accesses to this operation. This
// thread has created the operation, and now releases it so that the handler
// thread may handle the associated operation w/o triggering a race condition;
// thus this tag will be acquired just before the operation is handled in the
// handle_operations functor.
call_itt_notify(releasing, &(op.status));
// insert the operation into the list
do {
// ITT may flag the following line as a race; it is a false positive:
// This is an atomic read; we don't provide itt_hide_load_word for atomics
op.my_next = res = mailbox; // NOT A RACE
} while (mailbox.compare_and_swap(&op, res) != res);
if (!res) { // first in the list; handle the operations
// ITT note: &mailbox tag covers access to the handler_busy flag, which this
// waiting handler thread will try to set before entering handle_operations.
call_itt_notify(acquired, &mailbox);
start_handle_operations();
__TBB_ASSERT(op.status, NULL);
}
else { // not first; wait for op to be ready
call_itt_notify(prepare, &(op.status));
spin_wait_while_eq(op.status, uintptr_t(aggregator_operation::agg_waiting));
itt_load_word_with_acquire(op.status);
}
}
__TBB_ASSERT
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
tbb::internal::acquired
@ acquired
Definition: tbb_profiling.h:129
tbb::internal::releasing
@ releasing
Definition: tbb_profiling.h:129
tbb::internal::prepare
@ prepare
Definition: tbb_profiling.h:129
tbb::internal::itt_load_word_with_acquire
T itt_load_word_with_acquire(const tbb::atomic< T > &src)
Definition: tbb_profiling.h:168
tbb::internal::call_itt_notify
void call_itt_notify(notify_type, void *)
Definition: tbb_profiling.h:276
tbb::internal::spin_wait_while_eq
void spin_wait_while_eq(const volatile T &location, U value)
Spin WHILE the value of the variable is equal to a given value.
Definition: tbb_machine.h:394
tbb::interface6::aggregator_operation::agg_waiting
@ agg_waiting
Definition: aggregator.h:40
tbb::interface6::aggregator_ext::start_handle_operations
void start_handle_operations()
Trigger the handling of operations when the handler is free.
Definition: aggregator.h:148

References __TBB_ASSERT, tbb::internal::acquired, tbb::interface6::aggregator_operation::agg_waiting, tbb::internal::call_itt_notify(), tbb::internal::itt_load_word_with_acquire(), tbb::interface6::aggregator_operation::my_next, tbb::internal::prepare, tbb::internal::releasing, tbb::internal::spin_wait_while_eq(), and tbb::interface6::aggregator_operation::status.

Here is the call graph for this function:

## process()

template<typename handler_type >

void tbb::interface6::aggregator_ext< handler_type >::process | ( | aggregator_operation * | op | ) |

inline

EXPERT INTERFACE: Enter a user-made operation into the aggregator's mailbox.

Details of user-made operations must be handled by user-provided handler

Definition at line 102 of file aggregator.h.

{ execute_impl(*op); }
tbb::interface6::aggregator_ext::execute_impl
void execute_impl(aggregator_operation &op)
Definition: aggregator.h:107

## start_handle_operations()

template<typename handler_type >

void tbb::interface6::aggregator_ext< handler_type >::start_handle_operations | ( |  | ) |

inline private

Trigger the handling of operations when the handler is free.

Definition at line 148 of file aggregator.h.

{
aggregator_operation *pending_operations;
// ITT note: &handler_busy tag covers access to mailbox as it is passed
// between active and waiting handlers. Below, the waiting handler waits until
// the active handler releases, and the waiting handler acquires &handler_busy as
// it becomes the active_handler. The release point is at the end of this
// function, when all operations in mailbox have been handled by the
// owner of this aggregator.
call_itt_notify(prepare, &handler_busy);
// get handler_busy: only one thread can possibly spin here at a time
spin_wait_until_eq(handler_busy, uintptr_t(0));
call_itt_notify(acquired, &handler_busy);
// acquire fence not necessary here due to causality rule and surrounding atomics
__TBB_store_with_release(handler_busy, uintptr_t(1));
// ITT note: &mailbox tag covers access to the handler_busy flag itself.
// Capturing the state of the mailbox signifies that handler_busy has been
// set and a new active handler will now process that list's operations.
call_itt_notify(releasing, &mailbox);
// grab pending_operations
pending_operations = mailbox.fetch_and_store(NULL);
// handle all the operations
handle_operations(pending_operations);
// release the handler
itt_store_word_with_release(handler_busy, uintptr_t(0));
}
tbb::internal::spin_wait_until_eq
void spin_wait_until_eq(const volatile T &location, const U value)
Spin UNTIL the value of the variable is equal to a given value.
Definition: tbb_machine.h:402
tbb::internal::itt_store_word_with_release
void itt_store_word_with_release(tbb::atomic< T > &dst, U src)
Definition: tbb_profiling.h:157
tbb::internal::__TBB_store_with_release
void __TBB_store_with_release(volatile T &location, V value)
Definition: tbb_machine.h:716

References tbb::internal::__TBB_store_with_release(), tbb::internal::acquired, tbb::internal::call_itt_notify(), tbb::internal::itt_store_word_with_release(), tbb::internal::prepare, tbb::internal::releasing, and tbb::internal::spin_wait_until_eq().

Here is the call graph for this function:

## Member Data Documentation

## handle_operations

template<typename handler_type >

handler_type tbb::interface6::aggregator_ext< handler_type >::handle_operations

private

Definition at line 145 of file aggregator.h.

## handler_busy

template<typename handler_type >

uintptr_t tbb::interface6::aggregator_ext< handler_type >::handler_busy

private

Controls thread access to handle_operations.

Behaves as boolean flag where 0=false, 1=true

Definition at line 143 of file aggregator.h.

## mailbox

template<typename handler_type >

atomic<aggregator_operation *> tbb::interface6::aggregator_ext< handler_type >::mailbox

private

An atomically updated list (aka mailbox) of aggregator_operations.

Definition at line 139 of file aggregator.h.

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

- aggregator.h

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.