Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load the initial tail non-atomically in ponyint_mpmcq_pop #1624

Merged
merged 1 commit into from
Mar 3, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/libponyrt/sched/mpmcq.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,14 @@ void ponyint_mpmcq_push_single(mpmcq_t* q, void* data)
void* ponyint_mpmcq_pop(mpmcq_t* q)
{
#ifdef PLATFORM_IS_X86
PONY_ABA_PROTECTED(mpmcq_node_t*) cmp = bigatomic_load_explicit(&q->tail,
memory_order_relaxed);
PONY_ABA_PROTECTED(mpmcq_node_t*) cmp;
PONY_ABA_PROTECTED(mpmcq_node_t*) xchg;
mpmcq_node_t* tail;
// Load the tail non-atomically. If object and counter are out of sync, we'll
// do an additional CAS iteration which isn't less efficient than doing an
// atomic initial load.
cmp.object = q->tail.object;
cmp.counter = q->tail.counter;
#else
mpmcq_node_t* tail = atomic_load_explicit(&q->tail, memory_order_relaxed);
#endif
Expand Down