containing <ahref="Concepts.html#%28tech._vm%29"class="techoutside"data-pltdoc="x"><spanclass="techinside">VM</span></a> is based on <ahref="#%28tech._handler._function%29"class="techoutside"data-pltdoc="x"><spanclass="techinside">handler functions</span></a> exchanging
<ahref="Concepts.html#%28tech._event%29"class="techoutside"data-pltdoc="x"><spanclass="techinside">event</span></a> and <ahref="Concepts.html#%28tech._action%29"class="techoutside"data-pltdoc="x"><spanclass="techinside">action</span></a> structures with the VM. Both events and
actions are simple Racket structures.</p><p>This low-level interface between a VM and a process is analogous to
the <spanstyle="font-style: italic">system call interface</span> of a Unix-like operating system. The
<ahref="high-level-interface.html"data-pltdoc="x">High-level interface</a> corresponds to the <spanstyle="font-style: italic">C library
interface</span> of a Unix-like operating system.</p><h4>3.1<tt> </tt><aname="(part._handler-functions)"></a>Handler Functions</h4><p>Each <aname="(tech._handler._function)"></a><spanstyle="font-style: italic">handler function</span> is always associated with a particular
<ahref="Concepts.html#%28tech._endpoint%29"class="techoutside"data-pltdoc="x"><spanclass="techinside">endpoint</span></a>, registered with the VM via
<spanclass="RktSym">endpoint</span>/<spanclass="RktSym">endpoint:</span>/<spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">add-endpoint</span></span></span>. A handler
function for a given process with state type <spanclass="RktSym">State</span> has type:</p><blockquoteclass="SCodeFlow"><p><spanclass="RktPn">(</span><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">EndpointEvent</span></span></span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._-~3e%29%29"class="RktStxLink"data-pltdoc="x"><spanclass="nobreak">-></span></a></span><spanclass="hspace"> </span><spanclass="RktSym">State</span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._-~3e%29%29"class="RktStxLink"data-pltdoc="x"><spanclass="nobreak">-></span></a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">Transition</span></span></span><spanclass="hspace"> </span><spanclass="RktSym">State</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span></p></blockquote><p>That is, given an <spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">EndpointEvent</span></span></span> followed by the process’s
current state, the handler should reply with a <spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">Transition</span></span></span>
containing a new process state and a collection of <spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">Action</span></span></span>s.</p><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>type</p></div></div><pclass="RForeground"><aname="(def._((lib._marketplace/main..rkt)._.Handler))"></a><spantitle="Provided from: marketplace"><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">Handler</span></span></span></span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._.All%29%29"class="RktStxLink"data-pltdoc="x">All</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">State</span><spanclass="RktPn">)</span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">TrapK</span></span></span><spanclass="hspace"> </span><spanclass="RktSym">State</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span></p></blockquote></td></tr></table></td></tr><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>type</p></div></div><pclass="RForeground"><aname="(def._((lib._marketplace/main..rkt)._.Trap.K))"></a><spantitle="Provided from: marketplace"><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">TrapK</span></span></span></span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._.All%29%29"class="RktStxLink"data-pltdoc="x">All</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">State</span><spanclass="RktPn">)</span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">EndpointEvent</span></span></span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._-~3e%29%29"class="RktStxLink"data-pltdoc="x"><spanclass="nobreak">-></span></a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">InterruptK</span></span></span><spanclass="hspace"> </span><spanclass="RktSym">State</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span></p></blockquote></td></tr></table></td></tr><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>type</p></div></div><pclass="RForeground"><aname="(def._((lib._marketplace/main..rkt)._.Interrupt.K))"></a><spantitle="Provided from: marketplace"><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">InterruptK</span></span></span></span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._.All%29%29"class="RktStxLink"data-pltdoc="x">All</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">State</span><spanclass="RktPn">)</span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">State</span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="ht
which may have embedded wildcards.</div></p><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>value</p></div></div><pclass="RForeground"><aname="(def._((lib._marketplace/main..rkt)._~3f))"></a><spantitle="Provided from: marketplace"><spanclass="RktSym">?</span></span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">Topic</span></span></span></p></blockquote></td></tr></table></blockquote></div><divclass="SIntrapara">Each time <spanclass="RktSym">?</span> is used in an expression context, it produces a
fresh topic wildcard, suitable for use in a topic pattern.</div></p><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>struct</p></div></div><tablecellspacing="0"class="RForeground"><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29"class="RktStxLink"data-pltdoc="x">struct</a></span></td><td><spanclass="hspace"> </span></td><td><aname="(def._((lib._marketplace/main..rkt)._role-interest-type))"></a><aname="(def._((lib._marketplace/main..rkt)._role-topic))"></a><aname="(def._((lib._marketplace/main..rkt)._role-orientation))"></a><aname="(def._((lib._marketplace/main..rkt)._role~3f))"></a><aname="(def._((lib._marketplace/main..rkt)._struct~3arole))"></a><aname="(def._((lib._marketplace/main..rkt)._role))"></a><spantitle="Provided from: marketplace"><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">role</span></span></span></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">orientation</span><spanclass="stt"></span><spanclass="RktSym">topic</span><spanclass="stt"></span><spanclass="RktSym">interest-type</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span></td><td><spanclass="hspace"> </span></td><td><spanclass="RktPn">#:prefab</span><spanclass="RktPn">)</span></td></tr></table></blockquote></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktSym">orientation</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">Orientation</span></span></span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktSym">topic</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">Topic</span></span></span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktSym">interest-type</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">InterestType</span></span></span></td></tr></table></td></tr><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>type</p></div></div><pclass="RForeground"><aname="(def._((lib._marketplace/main..rkt)._.Role))"></a><spantitle="Provided from: marketplace"><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">Role</span></span></span></span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">role</span></span></span></p></blockquote></td></tr></table></td></tr></table></blockquote></div><divclass="SIntrapara">Roles are almost always constructed by the
<spanclass="RktSym">endpoint</span>/<spanclass="RktSym">endpoint:</span> macros or by the VM
implementations themselves. User programs generally only need to
destructure <spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">role</span></span></span> instances.</div></p><p>A <spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">role</span></span></span> describes the conversational role of a peer as seen by
some process. For example, a subscriber to topic <spanclass="RktVal">'</span><spanclass="RktVal">foo</span> with
interest-type <spanclass="RktVal">'</span><spanclass="RktVal">participant</span> might receive a presence
notification carrying the role</p><blockquoteclass="SCodeFlow"><p><spanclass="RktPn">(</span><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">role</span></span></span><spanclass="hspace"> </span><spanclass="RktVal">'</span><spanclass="RktVal">publisher</span><spanclass="hspace"> </span><spanclass="RktVal">'</span><spanclass="RktVal">foo</span><spanclass="hspace"> </span><spanclass="RktVal">'</span><spanclass="RktVal">participant</span><spanclass="RktPn">)</span></p></blockquote><p>Notice that the orientation of the role is the opposite of the
orientation of the endpoint.</p><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>type</p></div></div><pclass="RForeground"><aname="(def._((lib._marketplace/main..rkt)._.Orientation))"></a><spantitle="Provided from: marketplace"><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">Orientation</span></span></span></span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._.U%29%29"class="RktStxLink"data-pltdoc="x">U</a></span><spanclass="hspace"> </span><spanclass="RktVal">'</span><spanclass="RktVal">publisher</span><spanclass="hspace"> </span><spanclass="RktVal">'</span><spanclass="RktVal">subscriber</span><spanclass="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><divclass="SIntrapara">Describes an endpoint’s orientation: will it be acting as a publisher
of messages, or as a subscriber to messages? Publishers (orientation
<spanclass="RktVal">'</span><spanclass="RktVal">publisher</span>) tend to use <spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">send-message</span></span></span> and tend to
respond to feedback from subscribers; subscribers
(<spanclass="RktVal">'</span><spanclass="RktVal">subscriber</span>) tend to use <spanclass="RktSym">send-feedback</span> and respond
to messages from publishers.</div></p><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>type</p></div></div><pclass="RForeground"><aname="(def._((lib._marketplace/main..rkt)._.Interest.Type))"></a><spantitle="Provided from: marketplace"><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">InterestType</span></span></span></span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._.U%29%29"class="RktStxLink"data-pltdoc="x">U</a></span><spanclass="hspace"> </span><spanclass="RktVal">'</span><spanclass="RktVal">participant</span><spanclass="hspace"> </span><spanclass="RktVal">'</span><spanclass="RktVal">observer</span><spanclass="hspace"> </span><spanclass="RktVal">'</span><spanclass="RktVal">everything</span><spanclass="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><divclass="SIntrapara">Using interest-type <spanclass="RktVal">'</span><spanclass="RktVal">participant</span> in an endpoint’s role
indicates that the endpoint is intending to act as a genuine
participant in whatever protocol is associated with the endpoint and
its topic.</div></p><p>Using <spanclass="RktVal">'</span><spanclass="RktVal">observer</span> indicates that the endpoint is intended to
<spanstyle="font-style: italic">monitor</span> other ongoing (participant) conversations instead.
Observer endpoints receive presence and absence notifications about
participant endpoints, but participant endpoints only receive
notifications about other participant endpoints, and not about
observer endpoints.</p><p>The <spanclass="RktVal">'</span><spanclass="RktVal">observer</span> interest-type is intended to make it easier to
monitor resource demand and supply. The monitoring endpoints/processes
can react to changing demand by creating or destroying resources to
match.</p><p>Finally, the <spanclass="RktVal">'</span><spanclass="RktVal">everything</span> interest-type receives notifications
about presence and absence of <spanstyle="font-style: italic">all</span> the types of endpoint,
<spanclass="RktVal">'</span><spanclass="RktVal">participant</span>, <spanclass="RktVal">'</span><spanclass="RktVal">observer</span>, and <spanclass="RktVal">'</span><spanclass="RktVal">everything</span>.
Endpoints with interest-type <spanclass="RktVal">'</span><spanclass="RktVal">everything</span> are rare: they are
relevant for managing demand for <spanstyle="font-style: italic">observers</span>, as well as in some
cases of cross-layer presence/absence propagation. Most programs (and
even most drivers) will not need to use the <spanclass="RktVal">'</span><spanclass="RktVal">everything</span>
interest-type.</p><h4>3.3<tt> </tt><aname="(part._endpoint-events)"></a>Endpoint Events</h4><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>type</p></div></div><pclass="RForeground"><aname="(def._((lib._marketplace/main..rkt)._.Endpoint.Event))"></a><spantitle="Provided from: marketplace"><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">EndpointEvent</span></span></span></span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._.U%29%29"class="RktStxLink"data-pltdoc="x">U</a></span><spanclass="hspace"> </span><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">PresenceEvent</span></span></span><spanclass="hspace"> </span><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">AbsenceEvent</span></span></span><spanclass="hspace"> </span><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">MessageEvent</span></span></span><spanclass="RktPn">)</span></p></blockquote></td></tr></table></td></tr><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>type</p></div></div><pclass="RForeground"><aname="(def._((lib._marketplace/main..rkt)._.Presence.Event))"></a><spantitle="Provided from: marketplace"><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">PresenceEvent</span></span></span></span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">presence-event</span></span></span></p></blockquote></td></tr></table></td></tr><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>type</p></div></div><pclass="RForeground"><aname="(def._((lib._marketplace/main..rkt)._.Absence.Event))"></a><spantitle="Provided from: marketplace"><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">AbsenceEvent</span></span></span></span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">absence-event</span></span></span></p></blockquote></td></tr></table></td></tr><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>type</p></div></div><pclass="RForeground"><aname="(def._((lib._marketplace/main..rkt)._.Message.Event))"></a><spantitle="Provided from: marketplace"><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">MessageEvent</span></span></span></span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">message-event</span></span></span></p></blockquote></td></tr></table></td></tr></table></blockquote></div><divclass="SIntrapara">Endpoint events are passed to handler functions by VMs, conveying some
change in the world the process lives in. An endpoint event can signal
the arrival or departure of a conversational peer, or can deliver a
message that has been sent on a VM’s IPC facility.</div></p><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>struct</p></div></div><tablecellspacing="0"class="RForeground"><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29"class="RktStxLink"data-pltdoc="x">struct</a></span></td><td><spanclass="hspace"> </span></td><td><aname="(def._((lib._marketplace/main..rkt)._presence-event-role))"></a><aname="(def._((lib._marketplace/main..rkt)._presence-event~3f))"></a><aname="(def._((lib._marketplace/main..rkt)._struct~3apresence-event))"></a><aname="(def._((lib._marketplace/main..rkt)._presence-event))"></a><spantitle="Provided from: marketplace"><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">presence-event</span></span></span></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">role</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span></td><td><spanclass="hspace"> </span></td><td><spanclass="RktPn">#:prefab</span><spanclass="RktPn">)</span></td></tr></table></blockquote></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktSym">role</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">Role</span></span></span></td></tr></table></blockquote></div><divclass="SIntrapara">Indicates the arrival of a new conversational partner: an endpoint
with a topic that intersects our own, with <spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">Orientation</span></span></span>
opposite to our own.</div></p><p>The <spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">presence-event-role</span></span></span> describes the arriving peer, or more
precisely, describes the shared interest between ourselves and the new
peer. In particular, the <spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">role-orientation</span></span></span> of the
<spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">presence-event-role</span></span></span> is the orientation that the <spanstyle="font-style: italic">peer</span>
supplied in its <spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">add-endpoint</span></span></span> structure.</p><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>struct</p></div></div><tablecellspacing="0"class="RForeground"><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29"class="RktStxLink"data-pltdoc="x">struct</a></span></td><td><spanclass="hspace"> </span></td><td><aname="(def._((lib._marketplace/main..rkt)._absence-event-reason))"></a><aname="(def._((lib._marketplace/main..rkt)._absence-event-role))"></a><aname="(def._((lib._marketplace/main..rkt)._absence-event~3f))"></a><aname="(def._((lib._marketplace/main..rkt)._struct~3aabsence-event))"></a><aname="(def._((lib._marketplace/main..rkt)._absence-event))"></a><spantitle="Provided from: marketplace"><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">absence-event</span></span></span></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">role</span><spanclass="stt"></span><spanclass="RktSym">reason</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span></td><td><spanclass="hspace"> </span></td><td><spanclass="RktPn">#:prefab</span><spanclass="RktPn">)</span></td></tr></table></blockquote></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktSym">role</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">Role</span></span></span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktSym">reason</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Any%29%29"class="RktStxLink"data-pltdoc="x">Any</a></span></td></tr></table></blockquote></div><divclass="SIntrapara">Indicates the departure of an existing conversational partner, through
either an explicit <spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">delete-endpoint</span></span></span> action or the implicit
deleting of all of a process’s endpoints when a process exits.</div></p><p>The <spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">absence-event-role</span></span></span> describes the departing peer,
analogously to <spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">presence-event-role</span></span></span>.</p><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>struct</p></div></div><tablecellspacing="0"class="RForeground"><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29"class="RktStxLink"data-pltdoc="x">struct</a></span></td><td><spanclass="hspace"> </span></td><td><aname="(def._((lib._marketplace/main..rkt)._message-event-message))"></a><aname="(def._((lib._marketplace/main..rkt)._message-event-role))"></a><aname="(def._((lib._marketplace/main..rkt)._message-event~3f))"></a><aname="(def._((lib._marketplace/main..rkt)._struct~3amessage-event))"></a><aname="(def._((lib._marketplace/main..rkt)._message-event))"></a><spantitle="Provided from: marketplace"><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">message-event</span></span></span></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">role</span><spanclass="stt"></span><spanclass="RktSym">message</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span></td><td><spanclass="hspace"> </span></td><td><spanclass="RktPn">#:prefab</span><spanclass="RktPn">)</span></td></tr></table></blockquote></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktSym">role</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">Role</span></span></span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktSym">message</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">Message</span></span></span></td></tr></table></blockquote></div><divclass="SIntrapara">Indicates the arrival of a message matching the topic pattern in the
in an <spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">at-meta-level</span></span></span> structure, the action is to apply to
<spanstyle="font-style: italic">the VM’s own containing VM</span>; otherwise, the action applies to
the process’s containing VM.</div></p><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>struct</p></div></div><tablecellspacing="0"class="RForeground"><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29"class="RktStxLink"data-pltdoc="x">struct</a></span></td><td><spanclass="hspace"> </span></td><td><aname="(def._((lib._marketplace/main..rkt)._at-meta-level-preaction))"></a><aname="(def._((lib._marketplace/main..rkt)._at-meta-level~3f))"></a><aname="(def._((lib._marketplace/main..rkt)._struct~3aat-meta-level))"></a><aname="(def._((lib._marketplace/main..rkt)._at-meta-level))"></a><spantitle="Provided from: marketplace"><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">at-meta-level</span></span></span></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">preaction</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span></td><td><spanclass="hspace"> </span></td><td><spanclass="RktPn">#:prefab</span><spanclass="RktPn">)</span></td></tr></table></blockquote></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktSym">preaction</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">PreAction</span></span></span><spanclass="hspace"> </span><spanclass="RktSym">State</span><spanclass="RktPn">)</span></td></tr></table></td></tr><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>type</p></div></div><pclass="RForeground"><aname="(def._((lib._marketplace/main..rkt)._.At.Meta.Level))"></a><spantitle="Provided from: marketplace"><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">AtMetaLevel</span></span></span></span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._.All%29%29"class="RktStxLink"data-pltdoc="x">All</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">State</span><spanclass="RktPn">)</span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">at-meta-level</span></span></span><spanclass="hspace"> </span><spanclass="RktSym">State</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span></p></blockquote></td></tr></table></td></tr></table></blockquote></div><divclass="SIntrapara">An <spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">at-meta-level</span></span></span> structure wraps a plain action, and makes it
apply to the outer VM instead of the inner VM (the default).</div></p><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>struct</p></div></div><tablecellspacing="0"class="RForeground"><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29"class="RktStxLink"data-pltdoc="x">struct</a></span></td><td><spanclass="hspace"> </span></td><td><aname="(def._((lib._marketplace/main..rkt)._yield-k))"></a><aname="(def._((lib._marketplace/main..rkt)._yield~3f))"></a><aname="(def._((lib._marketplace/main..rkt)._struct~3ayield))"></a><aname="(def._((lib._marketplace/main..rkt)._yield))"></a><spantitle="Provided from: marketplace"><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">yield</span></span></span></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">k</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span></td><td><spanclass="hspace"> </span></td><td><spanclass="RktPn">#:prefab</span><spanclass="RktPn">)</span></td></tr></table></blockquote></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktSym">k</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">InterruptK</span></span></span><spanclass="hspace"> </span><spanclass="RktSym">State</span><spanclass="RktPn">)</span></td></tr></table></td></tr><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>type</p></div></div><pclass="RForeground"><aname="(def._((lib._marketplace/main..rkt)._.Yield))"></a><spantitle="Provided from: marketplace"><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">Yield</span></span></span></span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._.All%29%29"class="RktStxLink"data-pltdoc="x">All</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">State</span><spanclass="RktPn">)</span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">yield</span></span></span><spanclass="hspace"> </span><spanclass="RktSym">State</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span></p></blockquote></td></tr></table></td></tr></table></blockquote></div><divclass="SIntrapara">Because current VM implementations are cooperatively scheduled, it can
sometimes be necessary to explicitly yield the CPU to other processes
using a <spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">yield</span></span></span> action. When control returns to the yielding
process, the <spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">yield-k</span></span></span> is invoked.</div></p><h5>3.4.1<tt> </tt><aname="(part._endpoints-and-messages)"></a>Endpoints and Messages</h5><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>struct</p></div></div><tablecellspacing="0"class="RForeground"><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29"class="RktStxLink"data-pltdoc="x">struct</a></span></td><td><spanclass="hspace"> </span></td><td><aname="(def._((lib._marketplace/main..rkt)._add-endpoint-handler))"></a><aname="(def._((lib._marketplace/main..rkt)._add-endpoint-role))"></a><aname="(def._((lib._marketplace/main..rkt)._add-endpoint-pre-eid))"></a><aname="(def._((lib._marketplace/main..rkt)._add-endpoint~3f))"></a><aname="(def._((lib._marketplace/main..rkt)._struct~3aadd-endpoint))"></a><aname="(def._((lib._marketplace/main..rkt)._add-endpoint))"></a><spantitle="Provided from: marketplace"><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">add-endpoint</span></span></span></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">pre-eid</span><spanclass="stt"></span><spanclass="RktSym">role</span><spanclass="stt"></span><spanclass="RktSym">handler</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span></td><td><spanclass="hspace"> </span></td><td><spanclass="RktPn">#:prefab</span><spanclass="RktPn">)</span></td></tr></table></blockquote></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktSym">pre-eid</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Any%29%29"class="RktStxLink"data-pltdoc="x">Any</a></span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktSym">role</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">Role</span></span></span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktSym">handler</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">Handler</span></span></span><spanclass="hspace"> </span><spanclass="RktSym">State</span><spanclass="RktPn">)</span></td></tr></table></td></tr><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>type</p></div></div><pclass="RForeground"><aname="(def._((lib._marketplace/main..rkt)._.Add.Endpoint))"></a><spantitle="Provided from: marketplace"><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">AddEndpoint</span></span></span></span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._.All%29%29"class="RktStxLink"data-pltdoc="x">All</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">State</span><spanclass="RktPn">)</span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">add-endpoint</span></span></span><spanclass="hspace"> </span><spanclass="RktSym">State</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span></p></blockquote></td></tr></table></td></tr>
events pertaining to the given role occur, the <spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">Handler</span></span></span> is
invoked.<spanclass="NoteBox"><spanclass="NoteContent">If invoked <spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">at-meta-level</span></span></span>, subscribes to events
in the containing VM’s container.</span></span></div></p><p>The name of the new endpoint will be the <spanclass="RktSym">pre-eid</span>; it must be
unique within the current process, but otherwise can be any value at
all. If the endpoint’s name matches an existing endpoint, and the new
role is the same as the existing endpoint’s role, the handler function
is <spanstyle="font-style: italic">replaced</span> in the existing endpoint.</p><p>To delete an endpoint, perform a <spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">delete-endpoint</span></span></span> action built
with the name of the endpoint to delete.</p><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>struct</p></div></div><tablecellspacing="0"class="RForeground"><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29"class="RktStxLink"data-pltdoc="x">struct</a></span></td><td><spanclass="hspace"> </span></td><td><aname="(def._((lib._marketplace/main..rkt)._delete-endpoint-reason))"></a><aname="(def._((lib._marketplace/main..rkt)._delete-endpoint-pre-eid))"></a><aname="(def._((lib._marketplace/main..rkt)._delete-endpoint~3f))"></a><aname="(def._((lib._marketplace/main..rkt)._struct~3adelete-endpoint))"></a><aname="(def._((lib._marketplace/main..rkt)._delete-endpoint))"></a><spantitle="Provided from: marketplace"><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">delete-endpoint</span></span></span></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">pre-eid</span><spanclass="stt"></span><spanclass="RktSym">reason</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span></td><td><spanclass="hspace"> </span></td><td><spanclass="RktPn">#:prefab</span><spanclass="RktPn">)</span></td></tr></table></blockquote></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktSym">pre-eid</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Any%29%29"class="RktStxLink"data-pltdoc="x">Any</a></span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktSym">reason</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Any%29%29"class="RktStxLink"data-pltdoc="x">Any</a></span></td></tr></table></td></tr><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>type</p></div></div><pclass="RForeground"><aname="(def._((lib._marketplace/main..rkt)._.Delete.Endpoint))"></a><spantitle="Provided from: marketplace"><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">DeleteEndpoint</span></span></span></span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">delete-endpoint</span></span></span></p></blockquote></td></tr></table></td></tr></table></blockquote></div><divclass="SIntrapara">Deletes an existing endpoint named <spanclass="RktSym">pre-eid</span>. The given
<spanclass="RktSym">reason</span> is passed along to peer endpoints as part of an
<spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">absence-event</span></span></span>.</div></p><p>If no specific reason is needed, it is conventional to supply
<spanclass="RktVal">#f</span> as the <spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">delete-endpoint-reason</span></span></span>.</p><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>struct</p></div></div><tablecellspacing="0"class="RForeground"><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29"class="RktStxLink"data-pltdoc="x">struct</a></span></td><td><spanclass="hspace"> </span></td><td><aname="(def._((lib._marketplace/main..rkt)._send-message-orientation))"></a><aname="(def._((lib._marketplace/main..rkt)._send-message-body))"></a><aname="(def._((lib._marketplace/main..rkt)._send-message~3f))"></a><aname="(def._((lib._marketplace/main..rkt)._struct~3asend-message))"></a><aname="(def._((lib._marketplace/main..rkt)._send-message))"></a><spantitle="Provided from: marketplace"><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">send-message</span></span></span></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">body</span><spanclass="stt"></span><spanclass="RktSym">orientation</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span></td><td><spanclass="hspace"> </span></td><td><spanclass="RktPn">#:prefab</span><spanclass="RktPn">)</span></td></tr></table></blockquote></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktSym">body</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">Message</span></span></span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktSym">orientation</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">Orientation</span></span></span></td></tr></table></td></tr><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>type</p></div></div><pclass="RForeground"><aname="(def._((lib._marketplace/main..rkt)._.Send.Message))"></a><spantitle="Provided from: marketplace"><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">SendMessage</span></span></span></span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">send-message</span></span></span></p></blockquote></td></tr></table></td></tr></table></blockquote></div><divclass="SIntrapara">Sends a message to peers.<spanclass="NoteBox"><spanclass="NoteContent">Or, if <spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">at-meta-level</span></span></span>, peers of
the containing VM.</span></span> The given <spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">Orientation</span></span></span> should describe the
role the sender is playing when sending this message: usually, it will
be <spanclass="RktVal">'</span><spanclass="RktVal">publisher</span>, but when the message is <spanstyle="font-style: italic">feedback</span> for
some publisher, it will be <spanclass="RktVal">'</span><spanclass="RktVal">subscriber</span>. See also
wrapped in an <spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">at-meta-level</span></span></span>, the new process will instead be
a sibling of the creating process’s VM.</span></span>. The <spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">spawn-k</span></span></span> runs in
the context of the <spanstyle="font-style: italic">creating</span> process, communicating to it the
PID of the new process.</div></p><p>The <spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">spawn-spec</span></span></span> describes the new process to be created. Its
<spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">process-spec-boot</span></span></span> field is a function taking the PID of the
new process and returning a "cotransition". Cotransitions use a
second-order encoding of existential types to guarantee that the VM
remains oblivious to the specific process state type of the new
process. The downside of this approach is its syntactic and type
complexity: see <spanclass="RktSym">spawn:</span> for an easier-to-use, higher-level
approach.</p><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>struct</p></div></div><tablecellspacing="0"class="RForeground"><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29"class="RktStxLink"data-pltdoc="x">struct</a></span></td><td><spanclass="hspace"> </span></td><td><aname="(def._((lib._marketplace/main..rkt)._quit-reason))"></a><aname="(def._((lib._marketplace/main..rkt)._quit-pid))"></a><aname="(def._((lib._marketplace/main..rkt)._quit~3f))"></a><aname="(def._((lib._marketplace/main..rkt)._struct~3aquit))"></a><aname="(def._((lib._marketplace/main..rkt)._quit))"></a><spantitle="Provided from: marketplace"><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">quit</span></span></span></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">pid</span><spanclass="stt"></span><spanclass="RktSym">reason</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span></td><td><spanclass="hspace"> </span></td><td><spanclass="RktPn">#:prefab</span><spanclass="RktPn">)</span></td></tr></table></blockquote></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktSym">pid</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Option%29%29"class="RktStxLink"data-pltdoc="x">Option</a></span><spanclass="hspace"> </span><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">PID</span></span></span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktSym">reason</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Any%29%29"class="RktStxLink"data-pltdoc="x">Any</a></span></td></tr></table></td></tr><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>type</p></div></div><pclass="RForeground"><aname="(def._((lib._marketplace/main..rkt)._.Quit))"></a><spantitle="Provided from: marketplace"><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">Quit</span></span></span></span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">quit</span></span></span></p></blockquote></td></tr></table></td></tr></table></blockquote></div><divclass="SIntrapara">Kills a sibling process.<spanclass="NoteBox"><spanclass="NoteContent">Or, if <spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">at-meta-level</span></span></span>, a sibling
process of the containing VM.</span></span> If <spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">quit-pid</span></span></span> is <spanclass="RktVal">#f</span>,
kills the current process; otherwise, kills the process with the given
PID. The <spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">quit-reason</span></span></span> is passed on to peers of
currently-active endpoints in the process to be killed, as part of a
<spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">absence-event</span></span></span>, just as if each active endpoint were deleted
manually before the process exited.</div></p><p>If no specific reason is needed, it is conventional to supply
<spanclass="RktVal">#f</span> as the <spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">quit-reason</span></span></span>.</p><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>type</p></div></div><pclass="RForeground"><aname="(def._((lib._marketplace/main..rkt)._.P.I.D))"></a><spantitle="Provided from: marketplace"><spanclass="RktSym"><spanclass="badlink"><spanclass="RktValLink">PID</span></span></span></span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Number%29%29"class="RktStxLink"data-pltdoc="x">Number</a></span></p></blockquote></td></tr></table></blockquote></div><divclass="SIntrapara">In the current VM implementations, process IDs are simply numbers.
PIDs are scoped to and allocated by each individual VM instance.</div></p><divclass="navsetbottom"><spanclass="navleft"> </span><spanclass="navright"> <ahref="high-level-interface.html"title="backward to "2 High-level interface""data-pltdoc="x">← prev</a> <ahref="index.html"title="up to "Marketplace: Network-Aware Programming""data-pltdoc="x">up</a> <ahref="Drivers.html"title="forward to "4 Drivers""data-pltdoc="x">next →</a></span> </div></div></div><divid="contextindicator"> </div></body></html>