marketplace-2014/low-level-interface.html

106 lines
99 KiB
HTML
Raw Normal View History

2013-05-20 20:45:07 +00:00
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2014-01-18 01:58:19 +00:00
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"/><title>3&nbsp;Low-level interface</title><link rel="stylesheet" type="text/css" href="scribble.css" title="default"/><link rel="stylesheet" type="text/css" href="racket.css" title="default"/><link rel="stylesheet" type="text/css" href="footnote.css" title="default"/><link rel="stylesheet" type="text/css" href="manual-style.css" title="default"/><link rel="stylesheet" type="text/css" href="manual-racket.css" title="default"/><script type="text/javascript" src="scribble-common.js"></script><!--[if IE 6]><style type="text/css">.SIEHidden { overflow: hidden; }</style><![endif]--></head><body id="scribble-racket-lang-org"><div class="tocset"><div class="tocview"><div class="tocviewlist tocviewlisttopspace"><div class="tocviewtitle"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,&quot;tocview_0&quot;);">&#9660;</a></td><td></td><td><a href="index.html" class="tocviewlink" data-pltdoc="x">Marketplace:<span class="mywbr"> &nbsp;</span> Network-<wbr></wbr>Aware Programming</a></td></tr></table></div><div class="tocviewsublisttop" style="display: block;" id="tocview_0"><table cellspacing="0" cellpadding="0"><tr><td align="right">1&nbsp;</td><td><a href="Concepts.html" class="tocviewlink" data-pltdoc="x">Concepts</a></td></tr><tr><td align="right">2&nbsp;</td><td><a href="high-level-interface.html" class="tocviewlink" data-pltdoc="x">High-<wbr></wbr>level interface</a></td></tr><tr><td align="right">3&nbsp;</td><td><a href="low-level-interface.html" class="tocviewselflink" data-pltdoc="x">Low-<wbr></wbr>level interface</a></td></tr><tr><td align="right">4&nbsp;</td><td><a href="Drivers.html" class="tocviewlink" data-pltdoc="x">Drivers</a></td></tr><tr><td align="right">5&nbsp;</td><td><a href="Management_and_Monitoring.html" class="tocviewlink" data-pltdoc="x">Management and Monitoring</a></td></tr><tr><td align="right">6&nbsp;</td><td><a href="Examples.html" class="tocviewlink" data-pltdoc="x">Examples</a></td></tr></table></div></div><div class="tocviewlist"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,&quot;tocview_1&quot;);">&#9658;</a></td><td>3&nbsp;</td><td><a href="low-level-interface.html" class="tocviewselflink" data-pltdoc="x">Low-<wbr></wbr>level interface</a></td></tr></table><div class="tocviewsublistbottom" style="display: none;" id="tocview_1"><table cellspacing="0" cellpadding="0"><tr><td align="right">3.1&nbsp;</td><td><a href="low-level-interface.html#%28part._handler-functions%29" class="tocviewlink" data-pltdoc="x">Handler Functions</a></td></tr><tr><td align="right">3.2&nbsp;</td><td><a href="low-level-interface.html#%28part._.Messages__.Topics_and_.Roles%29" class="tocviewlink" data-pltdoc="x">Messages, Topics and Roles</a></td></tr><tr><td align="right">3.3&nbsp;</td><td><a href="low-level-interface.html#%28part._endpoint-events%29" class="tocviewlink" data-pltdoc="x">Endpoint Events</a></td></tr><tr><td align="right">3.4&nbsp;</td><td><a href="low-level-interface.html#%28part._.Actions%29" class="tocviewlink" data-pltdoc="x">Actions</a></td></tr></table></div></div></div><div class="tocsub"><div class="tocsubtitle">On this page:</div><table class="tocsublist" cellspacing="0"><tr><td><span class="tocsublinknumber">3.1<tt>&nbsp;</tt></span><a href="#%28part._handler-functions%29" class="tocsubseclink" data-pltdoc="x">Handler Functions</a></td></tr><tr><td><a href="#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Handler%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">Handler</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Trap.K%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">Trap<span class="mywbr"> &nbsp;</span>K</span></span></a></td></tr><tr><td>
containing <a href="Concepts.html#%28tech._vm%29" class="techoutside" data-pltdoc="x"><span class="techinside">VM</span></a> is based on <a href="low-level-interface.html#%28tech._handler._function%29" class="techoutside" data-pltdoc="x"><span class="techinside">handler functions</span></a> exchanging
2013-05-20 20:45:07 +00:00
<a href="Concepts.html#%28tech._event%29" class="techoutside" data-pltdoc="x"><span class="techinside">event</span></a> and <a href="Concepts.html#%28tech._action%29" class="techoutside" data-pltdoc="x"><span class="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 <span style="font-style: italic">system call interface</span> of a Unix-like operating system. The
<a href="high-level-interface.html" data-pltdoc="x">High-level interface</a> corresponds to the <span style="font-style: italic">C library
interface</span> of a Unix-like operating system.</p><h4>3.1<tt>&nbsp;</tt><a name="(part._handler-functions)"></a>Handler Functions</h4><p>Each <a name="(tech._handler._function)"></a><span style="font-style: italic">handler function</span> is always associated with a particular
<a href="Concepts.html#%28tech._endpoint%29" class="techoutside" data-pltdoc="x"><span class="techinside">endpoint</span></a>, registered with the VM via
2014-01-18 01:58:19 +00:00
<span class="RktSym">endpoint</span>/<span class="RktSym">endpoint:</span>/<span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._add-endpoint%29%29" class="RktValLink" data-pltdoc="x">add-endpoint</a></span>. A handler
function for a given process with state type <span class="RktSym">State</span> has type:</p><blockquote class="SCodeFlow"><p><span class="RktPn">(</span><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Endpoint.Event%29%29" class="RktValLink" data-pltdoc="x">EndpointEvent</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="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"><span class="nobreak">-&gt;</span></a></span><span class="hspace">&nbsp;</span><span class="RktSym">State</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="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"><span class="nobreak">-&gt;</span></a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="high-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Transition%29%29" class="RktValLink" data-pltdoc="x">Transition</a></span><span class="hspace">&nbsp;</span><span class="RktSym">State</span><span class="RktPn">)</span><span class="RktPn">)</span></p></blockquote><p>That is, given an <span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Endpoint.Event%29%29" class="RktValLink" data-pltdoc="x">EndpointEvent</a></span> followed by the process&rsquo;s
2013-05-29 21:26:03 +00:00
current state, the handler should reply with a <span class="RktSym"><a href="high-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Transition%29%29" class="RktValLink" data-pltdoc="x">Transition</a></span>
2014-01-18 01:58:19 +00:00
containing a new process state and a collection of <span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Action%29%29" class="RktValLink" data-pltdoc="x">Action</a></span>s.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" class="boxed RBoxed"><tr><td><table cellspacing="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>type</p></div></div><table cellspacing="0" class="argcontract RForeground"><tr><td><a name="(def._((lib._marketplace/main..rkt)._.Handler))"></a><span title="Provided from: marketplace"><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Handler%29%29" class="RktValDef RktValLink" data-pltdoc="x">Handler</a></span></span></td><td><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span></td><td><table cellspacing="0" class="RktBlk"><tr><td><span class="RktPn">(</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="RktSym"><a href="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><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">State</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Trap.K%29%29" class="RktValLink" data-pltdoc="x">TrapK</a></span><span class="hspace">&nbsp;</span><span class="RktSym">State</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr></table></blockquote></td></tr></table></td></tr><tr><td><table cellspacing="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>type</p></div></div><table cellspacing="0" class="argcontract RForeground"><tr><td><a name="(def._((lib._marketplace/main..rkt)._.Trap.K))"></a><span title="Provided from: marketplace"><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Trap.K%29%29" class="RktValDef RktValLink" data-pltdoc="x">TrapK</a></span></span></td><td><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span></td><td><table cellspacing="0" class="RktBlk"><tr><td><span class="RktPn">(</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="hspace">&nbsp;</span><span class="RktSym"><a href="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><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">State</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Endpoint.Event%29%29" class="RktValLink" data-pltdoc="x">EndpointEvent</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="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"><span class="nobreak">-&gt;</span></a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Interrupt.K%29%29" class="RktVal
2013-05-29 21:26:03 +00:00
and <a href="Concepts.html#%28tech._topic%29" class="techoutside" data-pltdoc="x"><span class="techinside">topics</span></a> are ordinary Racket values which may have embedded
2014-01-18 01:58:19 +00:00
wildcards.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" class="boxed RBoxed"><tr><td><table cellspacing="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._marketplace/main..rkt)._wild))"></a><span title="Provided from: marketplace, marketplace/sugar-untyped, marketplace/sugar-typed"><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._wild%29%29" class="RktValDef RktValLink" data-pltdoc="x">wild</a></span></span><span class="RktPn"></span><span class="RktPn">)</span><span class="hspace">&nbsp;</span>&rarr;<span class="hspace">&nbsp;</span><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Topic%29%29" class="RktValLink" data-pltdoc="x">Topic</a></span></p></blockquote></td></tr></table></td></tr><tr><td><table cellspacing="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><a name="(def._((lib._marketplace/sugar-untyped..rkt)._~3f))"></a><span title="Provided from: marketplace, marketplace/sugar-untyped, marketplace/sugar-typed"><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">?</a></span></span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Topic%29%29" class="RktValLink" data-pltdoc="x">Topic</a></span></p></blockquote></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">Each time <span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._~3f%29%29" class="RktValLink" data-pltdoc="x">?</a></span> (or <span class="RktPn">(</span><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._wild%29%29" class="RktValLink" data-pltdoc="x">wild</a></span><span class="RktPn">)</span>) is used in an expression
2013-05-29 21:26:03 +00:00
context, it produces a fresh topic wildcard, suitable for use in a
2014-01-18 01:58:19 +00:00
topic pattern.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" class="boxed RBoxed"><tr><td><table cellspacing="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>struct</p></div></div><table cellspacing="0" class="RForeground"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="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><span class="hspace">&nbsp;</span></td><td><a name="(def._((lib._marketplace/main..rkt)._role-interest-type))"></a><a name="(def._((lib._marketplace/main..rkt)._role-topic))"></a><a name="(def._((lib._marketplace/main..rkt)._role-orientation))"></a><a name="(def._((lib._marketplace/main..rkt)._role~3f))"></a><a name="(def._((lib._marketplace/main..rkt)._struct~3arole))"></a><a name="(def._((lib._marketplace/main..rkt)._role))"></a><span title="Provided from: marketplace, marketplace/sugar-untyped, marketplace/sugar-typed"><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._role%29%29" class="RktValDef RktValLink" data-pltdoc="x">role</a></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">orientation</span><span class="stt"> </span><span class="RktSym">topic</span><span class="stt"> </span><span class="RktSym">interest-type</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="RktPn">#:prefab</span><span class="RktPn">)</span></td></tr></table></blockquote></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktSym">orientation</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Orientation%29%29" class="RktValLink" data-pltdoc="x">Orientation</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktSym">topic</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Topic%29%29" class="RktValLink" data-pltdoc="x">Topic</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktSym">interest-type</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Interest.Type%29%29" class="RktValLink" data-pltdoc="x">InterestType</a></span></td></tr></table></td></tr><tr><td><table cellspacing="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>type</p></div></div><p class="RForeground"><a name="(def._((lib._marketplace/main..rkt)._.Role))"></a><span title="Provided from: marketplace, marketplace/sugar-untyped, marketplace/sugar-typed"><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Role%29%29" class="RktValDef RktValLink" data-pltdoc="x">Role</a></span></span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._role%29%29" class="RktValLink" data-pltdoc="x">role</a></span></p></blockquote></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">Roles are almost always constructed by the
2013-06-11 00:04:06 +00:00
<span class="RktSym">endpoint</span>/<span class="RktSym">endpoint:</span> macros or by the VM
2013-05-20 20:45:07 +00:00
implementations themselves. User programs generally only need to
2014-01-18 01:58:19 +00:00
destructure <span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._role%29%29" class="RktValLink" data-pltdoc="x">role</a></span> instances.</div></p><p>A <span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._role%29%29" class="RktValLink" data-pltdoc="x">role</a></span> describes the conversational role of a peer as seen by
2013-05-20 22:14:06 +00:00
some process. For example, a subscriber to topic <span class="RktVal">'</span><span class="RktVal">foo</span> with
interest-type <span class="RktVal">'</span><span class="RktVal">participant</span> might receive a presence
2014-01-18 01:58:19 +00:00
notification carrying the role</p><blockquote class="SCodeFlow"><p><span class="RktPn">(</span><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._role%29%29" class="RktValLink" data-pltdoc="x">role</a></span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">publisher</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">foo</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">participant</span><span class="RktPn">)</span></p></blockquote><p>Notice that the orientation of the role is the opposite of the
orientation of the endpoint.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>type</p></div></div><p class="RForeground"><a name="(def._((lib._marketplace/main..rkt)._.Orientation))"></a><span title="Provided from: marketplace, marketplace/sugar-untyped, marketplace/sugar-typed"><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Orientation%29%29" class="RktValDef RktValLink" data-pltdoc="x">Orientation</a></span></span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="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><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">publisher</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">subscriber</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">Describes an endpoint&rsquo;s orientation: will it be acting as a publisher
2013-05-20 22:14:06 +00:00
of messages, or as a subscriber to messages? Publishers (orientation
2013-05-29 21:26:03 +00:00
<span class="RktVal">'</span><span class="RktVal">publisher</span>) tend to use <span class="RktSym"><a href="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._send-message%29%29" class="RktValLink" data-pltdoc="x">send-message</a></span> and tend to
2013-05-20 22:14:06 +00:00
respond to feedback from subscribers; subscribers
2013-05-29 21:26:03 +00:00
(<span class="RktVal">'</span><span class="RktVal">subscriber</span>) tend to use <span class="RktSym"><a href="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._send-feedback%29%29" class="RktValLink" data-pltdoc="x">send-feedback</a></span> and respond
2014-01-18 01:58:19 +00:00
to messages from publishers.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>type</p></div></div><p class="RForeground"><a name="(def._((lib._marketplace/main..rkt)._.Interest.Type))"></a><span title="Provided from: marketplace, marketplace/sugar-untyped, marketplace/sugar-typed"><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Interest.Type%29%29" class="RktValDef RktValLink" data-pltdoc="x">InterestType</a></span></span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="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><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">participant</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">observer</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">everything</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">Using interest-type <span class="RktVal">'</span><span class="RktVal">participant</span> in an endpoint&rsquo;s role
2013-05-20 22:14:06 +00:00
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 <span class="RktVal">'</span><span class="RktVal">observer</span> indicates that the endpoint is intended to
<span style="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 <span class="RktVal">'</span><span class="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 <span class="RktVal">'</span><span class="RktVal">everything</span> interest-type receives notifications
about presence and absence of <span style="font-style: italic">all</span> the types of endpoint,
<span class="RktVal">'</span><span class="RktVal">participant</span>, <span class="RktVal">'</span><span class="RktVal">observer</span>, and <span class="RktVal">'</span><span class="RktVal">everything</span>.
Endpoints with interest-type <span class="RktVal">'</span><span class="RktVal">everything</span> are rare: they are
relevant for managing demand for <span style="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 <span class="RktVal">'</span><span class="RktVal">everything</span>
2014-01-18 01:58:19 +00:00
interest-type.</p><h4>3.3<tt>&nbsp;</tt><a name="(part._endpoint-events)"></a>Endpoint Events</h4><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" class="boxed RBoxed"><tr><td><table cellspacing="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>type</p></div></div><p class="RForeground"><a name="(def._((lib._marketplace/main..rkt)._.Endpoint.Event))"></a><span title="Provided from: marketplace"><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Endpoint.Event%29%29" class="RktValDef RktValLink" data-pltdoc="x">EndpointEvent</a></span></span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="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><span class="hspace">&nbsp;</span><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Presence.Event%29%29" class="RktValLink" data-pltdoc="x">PresenceEvent</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Absence.Event%29%29" class="RktValLink" data-pltdoc="x">AbsenceEvent</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Message.Event%29%29" class="RktValLink" data-pltdoc="x">MessageEvent</a></span><span class="RktPn">)</span></p></blockquote></td></tr></table></td></tr><tr><td><table cellspacing="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>type</p></div></div><p class="RForeground"><a name="(def._((lib._marketplace/main..rkt)._.Presence.Event))"></a><span title="Provided from: marketplace"><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Presence.Event%29%29" class="RktValDef RktValLink" data-pltdoc="x">PresenceEvent</a></span></span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._presence-event%29%29" class="RktValLink" data-pltdoc="x">presence-event</a></span></p></blockquote></td></tr></table></td></tr><tr><td><table cellspacing="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>type</p></div></div><p class="RForeground"><a name="(def._((lib._marketplace/main..rkt)._.Absence.Event))"></a><span title="Provided from: marketplace"><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Absence.Event%29%29" class="RktValDef RktValLink" data-pltdoc="x">AbsenceEvent</a></span></span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._absence-event%29%29" class="RktValLink" data-pltdoc="x">absence-event</a></span></p></blockquote></td></tr></table></td></tr><tr><td><table cellspacing="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>type</p></div></div><p class="RForeground"><a name="(def._((lib._marketplace/main..rkt)._.Message.Event))"></a><span title="Provided from: marketplace"><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Message.Event%29%29" class="RktValDef RktValLink" data-pltdoc="x">MessageEvent</a></span></span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._message-event%29%29" class="RktValLin
2013-05-20 20:45:07 +00:00
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
2014-01-18 01:58:19 +00:00
message that has been sent on a VM&rsquo;s IPC facility.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>struct</p></div></div><table cellspacing="0" class="RForeground"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="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><span class="hspace">&nbsp;</span></td><td><a name="(def._((lib._marketplace/main..rkt)._presence-event-role))"></a><a name="(def._((lib._marketplace/main..rkt)._presence-event~3f))"></a><a name="(def._((lib._marketplace/main..rkt)._struct~3apresence-event))"></a><a name="(def._((lib._marketplace/main..rkt)._presence-event))"></a><span title="Provided from: marketplace"><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._presence-event%29%29" class="RktValDef RktValLink" data-pltdoc="x">presence-event</a></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">role</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="RktPn">#:prefab</span><span class="RktPn">)</span></td></tr></table></blockquote></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktSym">role</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Role%29%29" class="RktValLink" data-pltdoc="x">Role</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Indicates the arrival of a new conversational partner: an endpoint
with a topic that intersects our own, with <span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Orientation%29%29" class="RktValLink" data-pltdoc="x">Orientation</a></span>
opposite to our own.</div></p><p>The <span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._presence-event-role%29%29" class="RktValLink" data-pltdoc="x">presence-event-role</a></span> describes the arriving peer, or more
2013-05-20 20:45:07 +00:00
precisely, describes the shared interest between ourselves and the new
2014-01-18 01:58:19 +00:00
peer. In particular, the <span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._role-orientation%29%29" class="RktValLink" data-pltdoc="x">role-orientation</a></span> of the
<span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._presence-event-role%29%29" class="RktValLink" data-pltdoc="x">presence-event-role</a></span> is the orientation that the <span style="font-style: italic">peer</span>
supplied in its <span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._add-endpoint%29%29" class="RktValLink" data-pltdoc="x">add-endpoint</a></span> structure.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>struct</p></div></div><table cellspacing="0" class="RForeground"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="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><span class="hspace">&nbsp;</span></td><td><a name="(def._((lib._marketplace/main..rkt)._absence-event-reason))"></a><a name="(def._((lib._marketplace/main..rkt)._absence-event-role))"></a><a name="(def._((lib._marketplace/main..rkt)._absence-event~3f))"></a><a name="(def._((lib._marketplace/main..rkt)._struct~3aabsence-event))"></a><a name="(def._((lib._marketplace/main..rkt)._absence-event))"></a><span title="Provided from: marketplace"><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._absence-event%29%29" class="RktValDef RktValLink" data-pltdoc="x">absence-event</a></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">role</span><span class="stt"> </span><span class="RktSym">reason</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="RktPn">#:prefab</span><span class="RktPn">)</span></td></tr></table></blockquote></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktSym">role</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Role%29%29" class="RktValLink" data-pltdoc="x">Role</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktSym">reason</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="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><div class="SIntrapara">Indicates the departure of an existing conversational partner, through
2013-05-29 21:26:03 +00:00
either an explicit <span class="RktSym"><a href="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._delete-endpoint%29%29" class="RktValLink" data-pltdoc="x">delete-endpoint</a></span> action or the implicit
2014-01-18 01:58:19 +00:00
deleting of all of a process&rsquo;s endpoints when a process exits.</div></p><p>The <span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._absence-event-role%29%29" class="RktValLink" data-pltdoc="x">absence-event-role</a></span> describes the departing peer,
analogously to <span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._presence-event-role%29%29" class="RktValLink" data-pltdoc="x">presence-event-role</a></span>.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>struct</p></div></div><table cellspacing="0" class="RForeground"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="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><span class="hspace">&nbsp;</span></td><td><a name="(def._((lib._marketplace/main..rkt)._message-event-message))"></a><a name="(def._((lib._marketplace/main..rkt)._message-event-role))"></a><a name="(def._((lib._marketplace/main..rkt)._message-event~3f))"></a><a name="(def._((lib._marketplace/main..rkt)._struct~3amessage-event))"></a><a name="(def._((lib._marketplace/main..rkt)._message-event))"></a><span title="Provided from: marketplace"><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._message-event%29%29" class="RktValDef RktValLink" data-pltdoc="x">message-event</a></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">role</span><span class="stt"> </span><span class="RktSym">message</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="RktPn">#:prefab</span><span class="RktPn">)</span></td></tr></table></blockquote></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktSym">role</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Role%29%29" class="RktValLink" data-pltdoc="x">Role</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktSym">message</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Message%29%29" class="RktValLink" data-pltdoc="x">Message</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Indicates the arrival of a message matching the topic pattern in the
handler&rsquo;s <a href="Concepts.html#%28tech._endpoint%29" class="techoutside" data-pltdoc="x"><span class="techinside">endpoint</span></a>.</div></p><h4>3.4<tt>&nbsp;</tt><a name="(part._.Actions)"></a>Actions</h4><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" class="boxed RBoxed"><tr><td><table cellspacing="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>type</p></div></div><table cellspacing="0" class="argcontract RForeground"><tr><td><a name="(def._((lib._marketplace/main..rkt)._.Action))"></a><span title="Provided from: marketplace"><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Action%29%29" class="RktValDef RktValLink" data-pltdoc="x">Action</a></span></span></td><td><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span></td><td><table cellspacing="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="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><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">State</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="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><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Pre.Action%29%29" class="RktValLink" data-pltdoc="x">PreAction</a></span><span class="hspace">&nbsp;</span><span class="RktSym">State</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._yield%29%29" class="RktStxLink" data-pltdoc="x">yield</a></span><span class="hspace">&nbsp;</span><span class="RktSym">State</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._at-meta-level%29%29" class="RktValLink" data-pltdoc="x">at-meta-level</a></span><span class="hspace">&nbsp;</span><span class="RktSym">State</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr></table></blockquote></td></tr></table></td></tr><tr><td><table cellspacing="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>type</p></div></div><table cellspacing="0" class="argcontract RForeground"><tr><td><a name="(def._((lib._marketplace/main..rkt)._.Pre.Action))"></a><span title="Provided from: marketplace"><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Pre.Action%29%29" class="RktValDef RktValLink" data-pltdoc="x">PreAction</a></span></span></td><td><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span></td><td><table cellspacing="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="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><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">State</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn"
2013-06-11 00:04:06 +00:00
in an <span class="RktSym"><a href="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._at-meta-level%29%29" class="RktValLink" data-pltdoc="x">at-meta-level</a></span> structure, the action is to apply to
2013-05-20 20:45:07 +00:00
<span style="font-style: italic">the VM&rsquo;s own containing VM</span>; otherwise, the action applies to
2014-01-18 01:58:19 +00:00
the process&rsquo;s containing VM.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" class="boxed RBoxed"><tr><td><table cellspacing="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>struct</p></div></div><table cellspacing="0" class="RForeground"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="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><span class="hspace">&nbsp;</span></td><td><a name="(def._((lib._marketplace/main..rkt)._at-meta-level-preaction))"></a><a name="(def._((lib._marketplace/main..rkt)._at-meta-level~3f))"></a><a name="(def._((lib._marketplace/main..rkt)._struct~3aat-meta-level))"></a><a name="(def._((lib._marketplace/main..rkt)._at-meta-level))"></a><span title="Provided from: marketplace"><span class="RktSym"><a href="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._at-meta-level%29%29" class="RktValDef RktValLink" data-pltdoc="x">at-meta-level</a></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">preaction</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="RktPn">#:prefab</span><span class="RktPn">)</span></td></tr></table></blockquote></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktSym">preaction</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Pre.Action%29%29" class="RktValLink" data-pltdoc="x">PreAction</a></span><span class="hspace">&nbsp;</span><span class="RktSym">State</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><table cellspacing="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>type</p></div></div><p class="RForeground"><a name="(def._((lib._marketplace/main..rkt)._.At.Meta.Level))"></a><span title="Provided from: marketplace"><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.At.Meta.Level%29%29" class="RktValDef RktValLink" data-pltdoc="x">AtMetaLevel</a></span></span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="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><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">State</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._at-meta-level%29%29" class="RktValLink" data-pltdoc="x">at-meta-level</a></span><span class="hspace">&nbsp;</span><span class="RktSym">State</span><span class="RktPn">)</span><span class="RktPn">)</span></p></blockquote></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">An <span class="RktSym"><a href="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._at-meta-level%29%29" class="RktValLink" data-pltdoc="x">at-meta-level</a></span> structure wraps a plain action, and makes it
apply to the outer VM instead of the inner VM (the default).</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" class="boxed RBoxed"><tr><td><table cellspacing="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>struct</p></div></div><table cellspacing="0" class="RForeground"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="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><span class="hspace">&nbsp;</span></td><td><a name="(def._((lib._marketplace/main..rkt)._yield-k))"></a><a name="(def._((lib._marketplace/main..rkt)._yield~3f))"></a><a name="(def._((lib._marketplace/main..rkt)._struct~3ayield))"></a><a name="(def._((lib._marketplace/main..rkt)._yield))"></a><span title="Provided from: marketplace"><span class="RktSym"><a href="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._yield%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">yield</a></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">k</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="RktPn">#:prefab</span><span class="RktPn">)</span></td></tr></table></blockquote></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktSym">k</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Interrupt.K%29%29" class="RktValLink" data-pltdoc="x">InterruptK</a></span><span class="hspace">&nbsp;</span><span class="RktSym">State</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><table cellspacing="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>type</p></div></div><p class="RForeground"><a name="(def._((lib._marketplace/main..rkt)._.Yield))"></a><span title="Provided from: marketplace"><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Yield%29%29" class="RktValDef RktValLink" data-pltdoc="x">Yield</a></span></span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="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><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">State</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._yield%29%29" class="RktStxLink" data-pltdoc="x">yield</a></span><span class="hspace">&nbsp;</span><span class="RktSym">State</span><span class="RktPn">)</span><span class="RktPn">)</span></p></blockquote></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">Because current VM implementations are cooperatively scheduled, it can
2013-05-20 20:45:07 +00:00
sometimes be necessary to explicitly yield the CPU to other processes
2013-05-29 21:26:03 +00:00
using a <span class="RktSym"><a href="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._yield%29%29" class="RktStxLink" data-pltdoc="x">yield</a></span> action. When control returns to the yielding
2014-01-18 01:58:19 +00:00
process, the <span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._yield-k%29%29" class="RktValLink" data-pltdoc="x">yield-k</a></span> is invoked.</div></p><h5>3.4.1<tt>&nbsp;</tt><a name="(part._endpoints-and-messages)"></a>Endpoints and Messages</h5><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" class="boxed RBoxed"><tr><td><table cellspacing="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>struct</p></div></div><table cellspacing="0" class="RForeground"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="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><span class="hspace">&nbsp;</span></td><td><a name="(def._((lib._marketplace/main..rkt)._add-endpoint-handler))"></a><a name="(def._((lib._marketplace/main..rkt)._add-endpoint-role))"></a><a name="(def._((lib._marketplace/main..rkt)._add-endpoint-pre-eid))"></a><a name="(def._((lib._marketplace/main..rkt)._add-endpoint~3f))"></a><a name="(def._((lib._marketplace/main..rkt)._struct~3aadd-endpoint))"></a><a name="(def._((lib._marketplace/main..rkt)._add-endpoint))"></a><span title="Provided from: marketplace"><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._add-endpoint%29%29" class="RktValDef RktValLink" data-pltdoc="x">add-endpoint</a></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">pre-eid</span><span class="stt"> </span><span class="RktSym">role</span><span class="stt"> </span><span class="RktSym">handler</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="RktPn">#:prefab</span><span class="RktPn">)</span></td></tr></table></blockquote></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktSym">pre-eid</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="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><span class="hspace">&nbsp;&nbsp;</span><span class="RktSym">role</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Role%29%29" class="RktValLink" data-pltdoc="x">Role</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktSym">handler</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Handler%29%29" class="RktValLink" data-pltdoc="x">Handler</a></span><span class="hspace">&nbsp;</span><span class="RktSym">State</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><table cellspacing="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>type</p></div></div><p class="RForeground"><a name="(def._((lib._marketplace/main..rkt)._.Add.Endpoint))"></a><span title="Provided from: marketplace"><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Add.Endpoint%29%29" class="RktValDef RktValLink" data-pltdoc="x">AddEndpoint</a></span></span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="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><span class="hspace">&nbsp;</span><span class="RktPn">
events pertaining to the given role occur, the <span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Handler%29%29" class="RktValLink" data-pltdoc="x">Handler</a></span> is
2013-06-11 00:04:06 +00:00
invoked.<span class="NoteBox"><span class="NoteContent">If invoked <span class="RktSym"><a href="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._at-meta-level%29%29" class="RktValLink" data-pltdoc="x">at-meta-level</a></span>, subscribes to events
2013-05-20 20:45:07 +00:00
in the containing VM&rsquo;s container.</span></span></div></p><p>The name of the new endpoint will be the <span class="RktSym">pre-eid</span>; it must be
unique within the current process, but otherwise can be any value at
all. If the endpoint&rsquo;s name matches an existing endpoint, and the new
role is the same as the existing endpoint&rsquo;s role, the handler function
2013-05-29 21:26:03 +00:00
is <span style="font-style: italic">replaced</span> in the existing endpoint.</p><p>To delete an endpoint, perform a <span class="RktSym"><a href="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._delete-endpoint%29%29" class="RktValLink" data-pltdoc="x">delete-endpoint</a></span> action built
2014-01-18 01:58:19 +00:00
with the name of the endpoint to delete.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" class="boxed RBoxed"><tr><td><table cellspacing="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>struct</p></div></div><table cellspacing="0" class="RForeground"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="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><span class="hspace">&nbsp;</span></td><td><a name="(def._((lib._marketplace/main..rkt)._delete-endpoint-reason))"></a><a name="(def._((lib._marketplace/main..rkt)._delete-endpoint-pre-eid))"></a><a name="(def._((lib._marketplace/main..rkt)._delete-endpoint~3f))"></a><a name="(def._((lib._marketplace/main..rkt)._struct~3adelete-endpoint))"></a><a name="(def._((lib._marketplace/main..rkt)._delete-endpoint))"></a><span title="Provided from: marketplace"><span class="RktSym"><a href="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._delete-endpoint%29%29" class="RktValDef RktValLink" data-pltdoc="x">delete-endpoint</a></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">pre-eid</span><span class="stt"> </span><span class="RktSym">reason</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="RktPn">#:prefab</span><span class="RktPn">)</span></td></tr></table></blockquote></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktSym">pre-eid</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="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><span class="hspace">&nbsp;&nbsp;</span><span class="RktSym">reason</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="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><table cellspacing="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>type</p></div></div><p class="RForeground"><a name="(def._((lib._marketplace/main..rkt)._.Delete.Endpoint))"></a><span title="Provided from: marketplace"><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Delete.Endpoint%29%29" class="RktValDef RktValLink" data-pltdoc="x">DeleteEndpoint</a></span></span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._delete-endpoint%29%29" class="RktValLink" data-pltdoc="x">delete-endpoint</a></span></p></blockquote></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">Deletes an existing endpoint named <span class="RktSym">pre-eid</span>. The given
2013-05-20 20:45:07 +00:00
<span class="RktSym">reason</span> is passed along to peer endpoints as part of an
2014-01-18 01:58:19 +00:00
<span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._absence-event%29%29" class="RktValLink" data-pltdoc="x">absence-event</a></span>.</div></p><p>If no specific reason is needed, it is conventional to supply
<span class="RktVal">#f</span> as the <span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._delete-endpoint-reason%29%29" class="RktValLink" data-pltdoc="x">delete-endpoint-reason</a></span>. See also the
2013-05-29 21:26:03 +00:00
convenience <span class="RktSym"><a href="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._delete-endpoint%29%29" class="RktValLink" data-pltdoc="x">delete-endpoint</a></span>
2014-01-18 01:58:19 +00:00
function from <span class="RktSym">marketplace/sugar-values</span>.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" class="boxed RBoxed"><tr><td><table cellspacing="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>struct</p></div></div><table cellspacing="0" class="RForeground"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="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><span class="hspace">&nbsp;</span></td><td><a name="(def._((lib._marketplace/main..rkt)._send-message-orientation))"></a><a name="(def._((lib._marketplace/main..rkt)._send-message-body))"></a><a name="(def._((lib._marketplace/main..rkt)._send-message~3f))"></a><a name="(def._((lib._marketplace/main..rkt)._struct~3asend-message))"></a><a name="(def._((lib._marketplace/main..rkt)._send-message))"></a><span title="Provided from: marketplace"><span class="RktSym"><a href="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._send-message%29%29" class="RktValDef RktValLink" data-pltdoc="x">send-message</a></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">body</span><span class="stt"> </span><span class="RktSym">orientation</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="RktPn">#:prefab</span><span class="RktPn">)</span></td></tr></table></blockquote></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktSym">body</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Message%29%29" class="RktValLink" data-pltdoc="x">Message</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktSym">orientation</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Orientation%29%29" class="RktValLink" data-pltdoc="x">Orientation</a></span></td></tr></table></td></tr><tr><td><table cellspacing="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>type</p></div></div><p class="RForeground"><a name="(def._((lib._marketplace/main..rkt)._.Send.Message))"></a><span title="Provided from: marketplace"><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Send.Message%29%29" class="RktValDef RktValLink" data-pltdoc="x">SendMessage</a></span></span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._send-message%29%29" class="RktValLink" data-pltdoc="x">send-message</a></span></p></blockquote></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">Sends a message to peers.<span class="NoteBox"><span class="NoteContent">Or, if <span class="RktSym"><a href="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._at-meta-level%29%29" class="RktValLink" data-pltdoc="x">at-meta-level</a></span>, peers of
the containing VM.</span></span> The given <span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Orientation%29%29" class="RktValLink" data-pltdoc="x">Orientation</a></span> should describe the
2013-05-20 20:45:07 +00:00
role the sender is playing when sending this message: usually, it will
be <span class="RktVal">'</span><span class="RktVal">publisher</span>, but when the message is <span style="font-style: italic">feedback</span> for
2013-05-29 21:26:03 +00:00
some publisher, it will be <span class="RktVal">'</span><span class="RktVal">subscriber</span>.
See also the <span class="RktSym"><a href="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._send-message%29%29" class="RktValLink" data-pltdoc="x">send-message</a></span> and
<span class="RktSym"><a href="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._send-feedback%29%29" class="RktValLink" data-pltdoc="x">send-feedback</a></span> convenience functions from
2014-01-18 01:58:19 +00:00
<span class="RktSym">marketplace/sugar-values</span>.</div></p><h5>3.4.2<tt>&nbsp;</tt><a name="(part._.Process_.Management)"></a>Process Management</h5><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" class="boxed RBoxed"><tr><td><table cellspacing="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>struct</p></div></div><table cellspacing="0" class="RForeground"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="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><span class="hspace">&nbsp;</span></td><td><a name="(def._((lib._marketplace/main..rkt)._spawn-debug-name))"></a><a name="(def._((lib._marketplace/main..rkt)._spawn-k))"></a><a name="(def._((lib._marketplace/main..rkt)._spawn-spec))"></a><a name="(def._((lib._marketplace/main..rkt)._spawn~3f))"></a><a name="(def._((lib._marketplace/main..rkt)._struct~3aspawn))"></a><a name="(def._((lib._marketplace/main..rkt)._spawn))"></a><span title="Provided from: marketplace"><span class="RktSym"><a href="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._spawn%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">spawn</a></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">spec</span><span class="stt"> </span><span class="RktSym">k</span><span class="stt"> </span><span class="RktSym">debug-name</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="RktPn">#:prefab</span><span class="RktPn">)</span></td></tr></table></blockquote></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktSym">spec</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._process-spec%29%29" class="RktValLink" data-pltdoc="x">process-spec</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktSym">k</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="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><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.P.I.D%29%29" class="RktValLink" data-pltdoc="x">PID</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="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"><span class="nobreak">-&gt;</span></a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Interrupt.K%29%29" class="RktValLink" data-pltdoc="x">InterruptK</a></span><span class="hspace">&nbsp;</span><span class="RktSym">State</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktSym">debug-name</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="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><table cellspacing="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>struct</p></div></div><table cellspacing="0" class=
2013-06-11 00:04:06 +00:00
wrapped in an <span class="RktSym"><a href="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._at-meta-level%29%29" class="RktValLink" data-pltdoc="x">at-meta-level</a></span>, the new process will instead be
2014-01-18 01:58:19 +00:00
a sibling of the creating process&rsquo;s VM.</span></span>. The <span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._spawn-k%29%29" class="RktValLink" data-pltdoc="x">spawn-k</a></span> runs in
2013-05-20 20:45:07 +00:00
the context of the <span style="font-style: italic">creating</span> process, communicating to it the
2014-01-18 01:58:19 +00:00
PID of the new process.</div></p><p>The <span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._spawn-spec%29%29" class="RktValLink" data-pltdoc="x">spawn-spec</a></span> describes the new process to be created. Its
<span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._process-spec-boot%29%29" class="RktValLink" data-pltdoc="x">process-spec-boot</a></span> field is a function taking the PID of the
2013-05-20 20:45:07 +00:00
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
2013-05-29 21:26:03 +00:00
complexity: see <span class="RktSym"><a href="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-typed..rkt%29._spawn~3a%29%29" class="RktStxLink" data-pltdoc="x">spawn:</a></span> for an easier-to-use, higher-level
2014-01-18 01:58:19 +00:00
approach.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" class="boxed RBoxed"><tr><td><table cellspacing="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>struct</p></div></div><table cellspacing="0" class="RForeground"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="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><span class="hspace">&nbsp;</span></td><td><a name="(def._((lib._marketplace/main..rkt)._quit-reason))"></a><a name="(def._((lib._marketplace/main..rkt)._quit-pid))"></a><a name="(def._((lib._marketplace/main..rkt)._quit~3f))"></a><a name="(def._((lib._marketplace/main..rkt)._struct~3aquit))"></a><a name="(def._((lib._marketplace/main..rkt)._quit))"></a><span title="Provided from: marketplace"><span class="RktSym"><a href="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._quit%29%29" class="RktValDef RktValLink" data-pltdoc="x">quit</a></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">pid</span><span class="stt"> </span><span class="RktSym">reason</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="RktPn">#:prefab</span><span class="RktPn">)</span></td></tr></table></blockquote></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktSym">pid</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="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><span class="hspace">&nbsp;</span><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.P.I.D%29%29" class="RktValLink" data-pltdoc="x">PID</a></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktSym">reason</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="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><table cellspacing="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>type</p></div></div><p class="RForeground"><a name="(def._((lib._marketplace/main..rkt)._.Quit))"></a><span title="Provided from: marketplace"><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Quit%29%29" class="RktValDef RktValLink" data-pltdoc="x">Quit</a></span></span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._quit%29%29" class="RktValLink" data-pltdoc="x">quit</a></span></p></blockquote></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">Kills a sibling process.<span class="NoteBox"><span class="NoteContent">Or, if <span class="RktSym"><a href="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._at-meta-level%29%29" class="RktValLink" data-pltdoc="x">at-meta-level</a></span>, a sibling
process of the containing VM.</span></span> If <span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._quit-pid%29%29" class="RktValLink" data-pltdoc="x">quit-pid</a></span> is <span class="RktVal">#f</span>,
2013-05-20 20:45:07 +00:00
kills the current process; otherwise, kills the process with the given
2014-01-18 01:58:19 +00:00
PID. The <span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._quit-reason%29%29" class="RktValLink" data-pltdoc="x">quit-reason</a></span> is passed on to peers of
2013-05-20 20:45:07 +00:00
currently-active endpoints in the process to be killed, as part of a
2014-01-18 01:58:19 +00:00
<span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._absence-event%29%29" class="RktValLink" data-pltdoc="x">absence-event</a></span>, just as if each active endpoint were deleted
2013-05-20 20:45:07 +00:00
manually before the process exited.</div></p><p>If no specific reason is needed, it is conventional to supply
2014-01-18 01:58:19 +00:00
<span class="RktVal">#f</span> as the <span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._quit-reason%29%29" class="RktValLink" data-pltdoc="x">quit-reason</a></span>.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>type</p></div></div><p class="RForeground"><a name="(def._((lib._marketplace/main..rkt)._.P.I.D))"></a><span title="Provided from: marketplace"><span class="RktSym"><a href="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.P.I.D%29%29" class="RktValDef RktValLink" data-pltdoc="x">PID</a></span></span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="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><div class="SIntrapara">In the current VM implementations, process IDs are simply numbers.
2013-05-20 20:45:07 +00:00
PIDs are scoped to and allocated by each individual VM instance.</div></p><div class="navsetbottom"><span class="navleft">&nbsp;&nbsp;</span><span class="navright">&nbsp;&nbsp;<a href="high-level-interface.html" title="backward to &quot;2 High-level interface&quot;" data-pltdoc="x">&larr; prev</a>&nbsp;&nbsp;<a href="index.html" title="up to &quot;Marketplace: Network-Aware Programming&quot;" data-pltdoc="x">up</a>&nbsp;&nbsp;<a href="Drivers.html" title="forward to &quot;4 Drivers&quot;" data-pltdoc="x">next &rarr;</a></span>&nbsp;</div></div></div><div id="contextindicator">&nbsp;</div></body></html>