home/ atoms/ chuck-event-signal-vs-broadcast

ChucK's `signal()` wakes one waiting shred while `broadcast()` wakes all

ChucK Events have two wake-up methods: signal() releases exactly one shred blocked on e => now, while broadcast() releases all waiting shreds simultaneously. Using signal() when several shreds are waiting leaves the rest permanently parked, a subtle cause of stuck voices. An Event that is never fired at all leaves every shred blocked on it parked forever.

Examples

Event e; // In three shreds: e => now; // each blocks e.signal(); // wakes exactly one e.broadcast(); // wakes all three

Assessment

A producer shred calls e.signal() once while three consumer shreds all block on e => now. How many wake, and what happens to the rest? Rewrite the call to wake all three.

“Event `signal()` wakes ONE, `broadcast()` wakes ALL.** Using `signal()` when you meant `broadcast()` leaves shreds stuck.”
context/ · L1-instruments/chuck/gotchas.md · chunk 1