Flags


A flag is a condition notification device which can be in one of two states: lowered (the initial state) or raised.

The flag can be raised at any time; raising a raised flag does nothing. Lowering a flag if it has not been raised yet will wait for another thread to raise the flag.

Essentially, a flag can be thought of as a counting semaphore where the count never goes above one.
flag

flag? ( object -- ? )


Waiting for a flag to be raised:
raise-flag ( flag -- )

wait-for-flag ( flag -- )

lower-flag ( flag -- )