On this page:
Evt
Evt.sync
Evt.wrap
Evt.Wrap  Return
Evt.Wrap  Return.no_  break
Evt.Wrap  Return.tail
Evt.always
Evt.never
Progress  Evt
Commit  Evt
Synchronizable
Synchronizable.as_  evt
8.17.0.6

15.4 Synchronizable Events🔗ℹ

A synchronizable events is an object that can be used with Evt.sync to wait until it is ready for synchronization. Synchronizing a ready event may have a side effect and an associated value. For example, synchronizing on a Semaphore is the same as using Semaphore.wait, so it decrements the semaphore’s count.

annotation

Evt

An annotation that recognizes synchronizable events, which include threads, semaphores, objects returned by methods like TCPListener.accept_evt, and objects that implement the Synchronizable interface.

The Evt annotation interface-like in the sense that every Evt supports the Evt.sync method.

method

method (evt :: Evt).sync(

  ~timeout: timeout_secs :: maybe(NonnegReal) = #false,

  ~enable_break: enable_break :: Any.to_boolean = #false,

  evt :: Evt,

  ...

) :: Any

Blocks until at least one of the evts is ready for synchronization, and returns the ready result. If multiple evts become ready before one is selected, one of the ready evts is selected at random.

method

method (evt :: Evt).wrap(

  ~return: return :: Evt.WrapReturn = #'no_break,

  wrapf :: (Any, ...) -> Any

) :: Evt

 

enumeration

enum Evt.WrapReturn:

  no_break

  tail

Creates an Evt that is ready for synchronization when evt is ready for synchronization, but whose synchronization result is determined by applying wrapf to the synchronization result of evt. The number of arguments accepted by wrapf must match the number of values for the synchronization result of evt.

If return is #'no_break, then wrapf is called with breaks (in the sense of Thread.break) disabled.

If return is #'tail, then wrapf is called in tail position with respect to a synchronization request via Evt.sync. When the Evt produced by Evt.wrap is wrapped by another Evt.wrap with #'no_break, however, this tail-call behavior is disabled.

value

def Evt.always :: Evt

 

value

def Evt.never :: Evt

The Evt.always synchronizable event is always ready for synchronization, and its synchronization result is itself.

The Evt.never synchronizable event is never ready for synchronization.

annotation

ProgressEvt

 

annotation

CommitEvt

A ProgressEvt is produced by Port.Input.Progress.evt to detect and synchronize reads from input ports that support progress events.

A CommitEvt is used in combination with a ProgressEvt for Port.Input.Progress.commit. A CommitEvt is either a Semaphore, channel-put event, channel, semaphore-peek event, Evt.always, or Evt.never.

An interface that a class can implement to make instances of the class usable as an Evt. When a class that implements Synchronizable is used with Evt.sync, the Synchronizable.as_evt method is called, and the result is used in the synchronization.

The interface has a single abstract method:

method

method (obj :: Synchronizable).as_evt() :: Evt

Obtains a synchronizable event for a Synchronizable object.