github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/engine/Readme.md (about) 1 # Notifier 2 The Notifier implements the following state machine 3 ![Notifier State Machine](/docs/NotifierStateMachine.png) 4 5 The intended usage pattern is: 6 * there are goroutines, aka `Producer`s, that append work to a queue `pendingWorkQueue` 7 * there is a number of goroutines, aka `Consumer`s, that pull work from the `pendingWorkQueue` 8 * they consume work until they have drained the `pendingWorkQueue` 9 * when they find that the `pendingWorkQueue` contains no more work, they go back to 10 the notifier and await notification 11 12 ![Notifier Usage Pattern](/docs/NotifierUsagePattern.png) 13 14 Note that the consumer / producer interact in a _different_ order with the `pendingWorkQueue` vs the `notifier`: 15 * the producer first drops its work into the queue and subsequently sends the notification 16 * the consumer first processes elements from the queue and subsequently checks for a notification 17 Thereby, it is guaranteed that at least one consumer routine will be notified when work is added 18