21 #ifndef __TBB__aggregator_H 22 #define __TBB__aggregator_H 24 #if !TBB_PREVIEW_AGGREGATOR 25 #error Set TBB_PREVIEW_AGGREGATOR before including aggregator.h 29 #include "tbb_profiling.h" 32 namespace interface6 {
41 enum aggregator_operation_status { agg_waiting=0, agg_finished };
44 void start() { call_itt_notify(acquired, &status); }
47 void finish() { itt_store_word_with_release(status, uintptr_t(agg_finished)); }
56 virtual void apply_body() = 0;
62 template<
typename Body>
65 void apply_body() { my_body(); }
83 op_list = op_list->next();
96 template <
typename handler_type>
99 aggregator_ext(
const handler_type& h) : handler_busy(0), handle_operations(h) { mailbox = NULL; }
116 call_itt_notify(releasing, &(op.status));
121 op.my_next = res = mailbox;
122 }
while (mailbox.compare_and_swap(&op, res) != res);
126 call_itt_notify(acquired, &mailbox);
127 start_handle_operations();
128 __TBB_ASSERT(op.status, NULL);
131 call_itt_notify(prepare, &(op.status));
132 spin_wait_while_eq(op.status, uintptr_t(aggregator_operation::agg_waiting));
133 itt_load_word_with_acquire(op.status);
144 uintptr_t handler_busy;
146 handler_type handle_operations;
149 void start_handle_operations() {
158 call_itt_notify(prepare, &handler_busy);
160 spin_wait_until_eq(handler_busy, uintptr_t(0));
161 call_itt_notify(acquired, &handler_busy);
163 __TBB_store_with_release(handler_busy, uintptr_t(1));
168 call_itt_notify(releasing, &mailbox);
170 pending_operations = mailbox.fetch_and_store(NULL);
173 handle_operations(pending_operations);
176 itt_store_word_with_release(handler_busy, uintptr_t(0));
187 template<
typename Body>
190 this->execute_impl(op);
202 #endif // __TBB__aggregator_H
Definition: aggregator.h:54
Definition: aggregator.h:63
Definition: aggregator.h:70
void finish()
Call finish when done handling this operation.
Definition: aggregator.h:47
Definition: aggregator.h:36
void process(aggregator_operation *op)
EXPERT INTERFACE: Enter a user-made operation into the aggregator's mailbox.
Definition: aggregator.h:103
void execute(const Body &b)
BASIC INTERFACE: Enter a function for exclusive execution by the aggregator.
Definition: aggregator.h:188
Primary template for atomic.
Definition: atomic.h:405
Definition: _flow_graph_async_msg_impl.h:32
Basic aggregator interface.
Definition: aggregator.h:181
The namespace tbb contains all components of the library.
Definition: parallel_for.h:44
Aggregator base class and expert interface.
Definition: aggregator.h:97
void execute_impl(aggregator_operation &op)
Place operation in mailbox, then either handle mailbox or wait for the operation to be completed by a...
Definition: aggregator.h:108
void start()
Call start before handling this operation.
Definition: aggregator.h:44