mirror of
https://github.com/NGSolve/netgen.git
synced 2024-11-11 16:49:16 +05:00
shared loop with relaxed memory ordering
This commit is contained in:
parent
a12e9bec61
commit
ad6ffaac05
@ -462,22 +462,26 @@ public:
|
||||
// return IntRange(begin, end);
|
||||
// }
|
||||
|
||||
bool PopFirst (size_t & first)
|
||||
bool PopFirst (size_t & hfirst)
|
||||
{
|
||||
// first = begin++;
|
||||
// return first < end;
|
||||
|
||||
first = begin;
|
||||
size_t first = begin.load(std::memory_order_relaxed);
|
||||
|
||||
size_t nextfirst = first+1;
|
||||
if (first >= end) nextfirst = std::numeric_limits<size_t>::max()-1;
|
||||
|
||||
while (!begin.compare_exchange_weak (first, nextfirst))
|
||||
// while (!begin.compare_exchange_weak (first, nextfirst))
|
||||
while (!begin.compare_exchange_weak (first, nextfirst,
|
||||
std::memory_order_relaxed,
|
||||
std::memory_order_relaxed))
|
||||
{
|
||||
first = begin;
|
||||
nextfirst = first+1;
|
||||
if (nextfirst >= end) nextfirst = std::numeric_limits<size_t>::max()-1;
|
||||
}
|
||||
hfirst = first;
|
||||
return first < end;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user