Skip to content

Commit

Permalink
Adding comment for get_with_id
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Hoeflinger <[email protected]>
  • Loading branch information
danhoeflinger committed Jan 22, 2025
1 parent 1b7f146 commit a2fb53b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion include/oneapi/dpl/pstl/omp/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ struct __enumerable_thread_local_storage
__thread_specific_storage.resize(__num_threads);
}

// Note: Size should not be used concurrently with parallel loops which may instantiate storage objects, as it may
// Note: size should not be used concurrently with parallel loops which may instantiate storage objects, as it may
// not return an accurate count of instantiated storage objects in lockstep with the number allocated and stored.
// This is because the count is not atomic with the allocation and storage of the storage objects.
std::size_t
Expand All @@ -179,6 +179,10 @@ struct __enumerable_thread_local_storage
return __num_elements.load();
}

// Note: get_with_id should not be used concurrently with parallel loops which may instantiate storage objects,
// as its operation may provide an out of date view of the stored objects based on the timing new object creation
// and incrementing of the size.
// TODO: Consider replacing this access with a visitor pattern.
_ValueType&
get_with_id(std::size_t __i)
{
Expand Down

0 comments on commit a2fb53b

Please sign in to comment.