FFORGE//RS
← Roadmap

rust / LEVEL 4

The future that starved its right branch

EST.45 MIN
01

THEORY / RETRIEVAL

What to restore

  • Explain the Future poll and Waker contract
  • Poll independent child futures fairly without busy-waiting
  • Retain completion state and never poll a finished child again

Pending is a scheduling contract

Future::poll must return quickly. Poll::Pending means the future cannot complete now and will arrange for the supplied Waker to be notified when progress may be possible. Spinning, blocking the executor thread, or waking unconditionally inside a combinator wastes capacity.

A join combinator owns two state machines

Independent children should each get a chance to progress during one outer poll. Once a child returns Ready, the combinator records that completion and must not poll the child again. The outer future returns Ready only after both child states are complete.

CHECKPOINT

The left child returns Pending while the independent right child is ready. What should a join combinator do in that outer poll?

ISOLATED RUST 1.96
src/lib.rsEDIT

02 / DEBUGGING

Find and fix the defect

Repair JoinReady::poll so each incomplete child is polled at most once per outer poll, a ready child is never polled again, and the join becomes Ready only after both finish. Keep the implementation safe and non-blocking.

Initializing editor…
CLOUD SANDBOXnetwork off · 256 MB · 12 s
2 / 64 KB
OUTPUT
Runner is waiting for a submission.