Skip to content
Merged
Show file tree
Hide file tree
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: 3 additions & 5 deletions src/libponyrt/actor/actor.c
Original file line number Diff line number Diff line change
Expand Up @@ -868,17 +868,15 @@ bool ponyint_triggers_muting(pony_actor_t* actor)

bool ponyint_is_muted(pony_actor_t* actor)
{
return (atomic_fetch_add_explicit(&actor->is_muted, 0, memory_order_relaxed) > 0);
return (atomic_load_explicit(&actor->is_muted, memory_order_relaxed) > 0);
}

void ponyint_mute_actor(pony_actor_t* actor)
{
uint8_t is_muted = atomic_load_explicit(&actor->is_muted, memory_order_relaxed);
uint8_t is_muted = atomic_fetch_add_explicit(&actor->is_muted, 1, memory_order_relaxed);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting. i found i had this at one point when doing this work but it was changed later on. i wonder why.

pony_assert(is_muted == 0);
DTRACE1(ACTOR_MUTED, (uintptr_t)actor);
is_muted++;
atomic_store_explicit(&actor->is_muted, is_muted, memory_order_relaxed);

(void)is_muted;
}

void ponyint_unmute_actor(pony_actor_t* actor)
Expand Down
12 changes: 5 additions & 7 deletions src/libponyrt/sched/scheduler.c
Original file line number Diff line number Diff line change
Expand Up @@ -1292,9 +1292,7 @@ void ponyint_sched_mute(pony_ctx_t* ctx, pony_actor_t* sender, pony_actor_t* rec
// This is safe because an actor can only ever be in a single scheduler's
// mutemap
ponyint_muteset_putindex(&mref->value, sender, index2);
size_t muted = atomic_load_explicit(&sender->muted, memory_order_relaxed);
muted++;
atomic_store_explicit(&sender->muted, muted, memory_order_relaxed);
atomic_fetch_add_explicit(&sender->muted, 1, memory_order_relaxed);
}
}

Expand Down Expand Up @@ -1327,12 +1325,12 @@ bool ponyint_sched_unmute_senders(pony_ctx_t* ctx, pony_actor_t* actor)
{
// This is safe because an actor can only ever be in a single scheduler's
// mutemap
size_t muted_count = atomic_load_explicit(&muted->muted, memory_order_relaxed);
size_t muted_count = atomic_fetch_sub_explicit(&muted->muted, 1, memory_order_relaxed);
pony_assert(muted_count > 0);
muted_count--;
atomic_store_explicit(&muted->muted, muted_count, memory_order_relaxed);

if (muted_count == 0)
// If muted_count used to be 1 before we decremented it; then the actor
// is longer muted
if(muted_count == 1)
{
needs_unmuting = ponyint_actorstack_push(needs_unmuting, muted);
}
Expand Down