Skip to content

Commit

Permalink
Correct fetch_item
Browse files Browse the repository at this point in the history
  • Loading branch information
kboyarinov committed Aug 15, 2024
1 parent 078f3ad commit fab7913
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions include/oneapi/tbb/detail/_flow_graph_item_buffer_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class item_buffer {
if(element(i).state != no_item) {
destroy_item(i);
}

new(&(element(i).item)) item_type(o);
new(&element(i).metainfo) message_metainfo(std::move(metainfo));
// Skipping the reservation on metainfo.waiters since the ownership
Expand All @@ -124,21 +124,22 @@ class item_buffer {
#endif

// destructively-fetch an object from the buffer
void fetch_item(size_t i, item_type &o) {
#if __TBB_PREVIEW_FLOW_GRAPH_TRY_PUT_AND_WAIT
void fetch_item(size_t i, item_type& o, message_metainfo& metainfo) {
__TBB_ASSERT(my_item_valid(i), "Trying to fetch an empty slot");
o = get_my_item(i); // could have std::move assign semantics
metainfo = std::move(get_my_metainfo(i));
destroy_item(i);
}

#if __TBB_PREVIEW_FLOW_GRAPH_TRY_PUT_AND_WAIT
void fetch_item(size_t i, item_type& o, message_metainfo& metainfo) {
#else
void fetch_item(size_t i, item_type &o) {
__TBB_ASSERT(my_item_valid(i), "Trying to fetch an empty slot");
o = get_my_item(i); // could have std::move assign semantics
metainfo = std::move(get_my_metainfo(i));
destroy_item(i);
}
#endif


// move an existing item from one slot to another. The moved-to slot must be unoccupied,
// the moved-from slot must exist and not be reserved. The after, from will be empty,
// to will be occupied but not reserved
Expand Down

0 comments on commit fab7913

Please sign in to comment.