Skip to content

Explore ManualResetEvent waiter storage and state fast paths #252

Description

@tisonkun

Background

PR #243 added ManualResetEvent with a mutex-protected boolean state and WaitList. Its approval review left the internal representation as a follow-up exploration: the ideas may improve the implementation, but keeping the current design is valid if the alternatives do not preserve its contracts or reduce overall cost.

Questions to explore

  1. Can ManualResetEvent replace WaitList and its per-waiter notified state with WaitSet while preserving the rule that every wait registered before set remains committed even if reset happens before its next poll?
  2. Can is_set and the already-set wait path use an atomic boolean, or another compact atomic state, instead of acquiring the state mutex on every observation?

Requirements

  • preserve the public API and the set/reset, first-poll registration, cancellation, and memory-publication contracts introduced by feat(event): add a manual-reset event #243;
  • prevent lost wake-ups across concurrent state checks, waiter registration, set, and reset;
  • keep waker clone, drop, and wake callbacks outside internal locks;
  • account for reentrant callbacks and a rapid set followed by reset;
  • compare complexity and benchmark results with the current implementation, including is_set, already-set waits, pending registration/cancellation, set/reset reuse, and fan-out;
  • prefer the current implementation if an alternative only moves complexity or lacks a meaningful workload benefit.

Follow-up to #221 and #243. The originating approval review is here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions