class Rosegold::InventoryDispatch

Overview

Orders one client's predicted menu clicks against guarded menu writes without holding any transport lock. A guarded intent is refused while another guarded intent or an ordinary click is in progress; an ordinary click waits only while a guarded write is flushing, so it predicts from committed state.

Defined in:

rosegold/inventory/inventory_dispatch.cr

Instance Method Summary

Instance Method Detail

def begin_flush : Channel(Nil) | Nil #

Called under the write lock once a guarded write is approved. Returns nil, refusing it, while an ordinary click is in progress.


[View source]
def end_flush(flush : Channel(Nil) | Nil) : Nil #

Called under the write lock whether or not the write happened, so waiters resume before a failed write's Disconnected listeners run.


[View source]
def guarded(& : -> Bool) : Bool #

Runs one guarded intent, or returns false at once if another guarded intent or an ordinary click is still in progress.


[View source]
def ordinary(&) #

Waits out a flushing guarded write, then runs an ordinary click, yielding whether it waited. Nothing is held while the block runs.


[View source]
def predicted : Nil #

[View source]
def revision : UInt64 #

Counts ordinary click predictions; guarded intents refuse if it moves.


[View source]