signature REMOTE structure Remote : REMOTE
This structure provides support for the implementation of distributed applications. This includes exporting values from and importing values into sites, performing remote function application and starting a new site. See the distribution overview for an introduction to the distribution facilities provided by Alice.
Communication between sites is performed by cloning data structures. Cloning is defined by pickling.
The current implementation uses HTTP as the transport protocol. Accordingly, tickets are URLs using the http scheme.
See also: COMPONENT_MANAGER, Url, Pickle
import structure Remote from "x-alice:/lib/distribution/Remote" import signature REMOTE from "x-alice:/lib/distribution/REMOTE-sig"
signature REMOTE = sig type ticket = string exception Ticket exception Sited exception Protocol of int * string val proxy : ('a -> 'b) -> ('a -> 'b) val offer : package -> ticket val take : ticket -> package functor Offer (signature S structure X : S) : (val ticket : ticket) functor Take (val ticket : ticket signature S) : S functor Execute (val host : string signature RESULT functor Start (ComponentManager : COMPONENT_MANAGER) : RESULT) : RESULT end
The type of tickets representing offered values. Tickets are short strings suitable for communication, for instance, over voice lines or by email. Tickets are suitable for parsing as URLs.
indicates that a ticket was not well-formed or referred to a site or value that could not be accessed.
indicates that the argument or result of a call to a proxy contained a sited value. Same as Component.Sited.
indicates a protocol error.
returns a proxy for f. The proxy differs from f in that:
the argument to the proxy is cloned before f is applied to it; if it contains a sited value, the exception Sited will be raised; if it contains a failed future, the causing exception will be raised;
the return value from f is cloned before it is returned from the proxy; if it contains a sited value, the exception Sited will be raised; if it contains a failed future, the causing exception will be raised; if the causing exception itself contains a sited value or a failed future, the exception Sited will be raised instead;
when the proxy is cloned, a reference to the running site is cloned which does not contain a clone of f;
when the proxy is applied no matter on which site, this causes f to be applied on the site on which the proxy was created.
When the site on which the proxy was created terminates, the proxy becomes invalid. Applications of the proxy on other sites will raise the Ticket exception.
makes package available to other sites for taking. Returns a ticket suitable for take or Take. If the argument is a mutable data structure, then taking returns a clone of how the data structure looked when the offer was initially made. An offered data structure can be taken any number of times.
imports the data structure denoted by ticket, which must have been created by offer or Offer. Raises Ticket if the ticket is invalid or the site on which it was created no longer exists.
makes X available to other sites for taking with signature S. Returns a ticket suitable for take or Take. If the argument is a mutable data structure, then taking returns a clone of how the data structure looked when the offer was initially made. Equivalent to
(val ticket = offer (pack X :> S))
imports the data structure denoted by ticket, which must have been created by offer or Offer, under signature S. Raises Ticket if the ticket is invalid or the site on which it was created no longer exists. Raises Package.Mismatch if the value was not exported with a signature matching S. Equivalent to
unpack (take ticket) : S
creates a new site on host using ssh, transfers a clone of Start to the new site, on which it is applied to the local component manager. A clone of the resulting structure is transferred back to the caller of Execute and returned as the resulting structure.