Verse Library verse

02 Fragment

Defines an event and uses Await/Signal to pause execution until another code path triggers it.

verse-library/verse-concurrency-async-race-state-machines/02-fragment.verse

# Declare an event that carries no payload
DoorOpened : event() = event(){}

# Somewhere, an async function waits for it:
#   DoorOpened.Await()        # pauses here until...
# ...somewhere else, code fires it:
#   DoorOpened.Signal()       # ...this runs, and the Await above wakes up

Comments

    Sign in to vote, comment, or suggest an edit. Sign in