diff --git a/src/syndicated-actor-model.md b/src/syndicated-actor-model.md index 73ffa75..46ea474 100644 --- a/src/syndicated-actor-model.md +++ b/src/syndicated-actor-model.md @@ -121,7 +121,7 @@ representing spreadsheet cells. Each cell entity publishes public aspects of its interested peers: namely, its current value. It also responds to messages instructing it to update its formula. In pseudocode: -    ` 1:`**define entity** Cell(*formula*): +    ` 1:`**define entity** Cell(*formula*):     ` 2:`    *subscribers* ← ∅     ` 3:`    **on** assertion from a peer of interest in our value,     ` 4:`        add *peer*, the entity reference carried in the assertion of interest, to *subscribers* @@ -136,6 +136,7 @@ update its formula. In pseudocode:     `13:`    **continuously**, whenever *value* or *subscribers* changes,     `14:`        **assert** the contents of *value* to every peer in *subscribers*,     `15:`        **retract**ing previously-asserted values + Much of the subscription-management behaviour of Cell is generic: lines 2–6 managing the *subscribers* set and lines 13–14 iterating over it will be common to any entity wishing to @@ -149,18 +150,20 @@ Hayes modem command strings) paired with *continuations* represented as entity r responses the modem sends in reply to a command string are delivered to the continuation entity as a SAM message. -    ` 1:`**define entity** Server(): +    ` 1:`**define entity** Server():     ` 2:`    **on** assertion Request(*commandString*, *replyEntity*)     ` 3:`        output *commandString* via modem serial port     ` 4:`        collect response(s) from modem serial port -    ` 5:`        **send** response(s) as a message to *replyEntity* - -    ` 6:`**define entity** Client(*serverRef*): +    ` 5:`        **send** response(s) as a message to *replyEntity* + + +    ` 6:`**define entity** Client(*serverRef*):     ` 7:`    **define entity** *k*:     ` 8:`        **on** message containing responses,     ` 9:`            **retract** the Request assertion     `10:`            (and continue with other tasks)     `11:`    **assert** Request(`"AT+CMGS=..."`, *k*) to *serverRef* + This is almost a standard continuation-passing style encoding of remote procedure call.[^rpc-sam-discussion] However, there is one important difference: the request is sent to @@ -193,7 +196,7 @@ the factoring-out of dataspaces. A special kind of syndicated actor entity, a *dataspace*, routes and replicates published data according to actors' interests. -    ` 1:`**define entity** Dataspace(): +    ` 1:`**define entity** Dataspace():     ` 2:`    *allAssertions* ← ∅     ` 3:`    *allSubscribers* ← ∅     ` 4:`    **on** assertion of semi-structured datum *a*, @@ -211,6 +214,7 @@ according to actors' interests.     `16:`        if *a* matches Observe(*pattern*, *subscriberRef*),     `17:`            remove (*pattern*, *subscriberRef*) from *allSubscribers*     `18:`            retract all assertions previously sent to *subscriberRef* + Assertions sent to a dataspace are routed by pattern-matching. Subscriptions—tuples associating a pattern with a subscriber entity—are placed in the dataspace as assertions like any other. @@ -297,7 +301,7 @@ modem examples from above. ### Spreadsheet cell with a dataspace -    ` 1:`**define entity** Cell(*dataspaceRef*, *name*, *formula*): +    ` 1:`**define entity** Cell(*dataspaceRef*, *name*, *formula*):     ` 2:`    **continuously**, whenever *value* changes,     ` 3:`        **assert** CellValue(*name*, *value*) to *dataspaceRef*     ` 4:`    **continuously**, whenever *formula* changes, @@ -308,6 +312,7 @@ modem examples from above.     ` 9:`            **assert** Observe(⌜CellValue(*n*, *?nValue*)⌝, *k*) to *dataspaceRef*     `10:`    **on** message conveying a new formula,     `11:`        *formula* ← *newFormula* + The cell is able to outsource all subscription management to the *dataspaceRef* it is given. Its behaviour function is looking much closer to an abstract prose specification of a @@ -319,20 +324,22 @@ There are many ways to implement RPC using dataspaces,[^rpc-sam-discussion] each characteristics. This implementation uses anonymous service instances, implicit service names, asserted requests, and message-based responses: -    ` 1:`**define entity** Server(*dataspaceRef*): +    ` 1:`**define entity** Server(*dataspaceRef*):     ` 2:`    **define entity** *serviceRef*:     ` 3:`        **on** assertion of *commandString* and *replyEntity*     ` 4:`            output *commandString* via modem serial port     ` 5:`            collect response(s) from modem serial port     ` 6:`            **send** response(s) as a message to *replyEntity*     ` 7:`    **assert** Observe(⌜Request(*?commandString*, *?replyEntity*)⌝, *serviceRef*) to *dataspaceRef* - -    ` 8:`**define entity** Client(*dataspaceRef*): + + +    ` 8:`**define entity** Client(*dataspaceRef*):     ` 9:`    **define entity** *k*:     `10:`        **on** message containing responses,     `11:`            **retract** the Request assertion     `12:`            (and continue with other tasks)     `13:`    **assert** Request(`"AT+CMGS=..."`, *k*) to *dataspaceRef* + If the service crashes before replying, the client's request remains outstanding, and a service supervisor [[Armstrong 2003][], section 4.3.2] can reset the modem and start a fresh service diff --git a/style.css b/style.css index a27ddaf..27f7d8b 100644 --- a/style.css +++ b/style.css @@ -6,3 +6,8 @@ div.ditaa { svg text { font-family: "Source Code Pro", Consolas, "Ubuntu Mono", Menlo, "DejaVu Sans Mono", monospace, monospace !important; } + +span.pseudocode { + white-space: nowrap; + overflow: auto; +}