Library for distributed programming with ports. This paper contains a description of the basic ideas behind this library.
Author: Michael Hanus
Version: December 2018
openPort
:: Port a -> [a] -> Bool
Opens an internal port for communication. |
send
:: a -> Port a -> Bool
Sends a message to a port. |
doSend
:: a -> Port a -> IO ()
I/O action that sends a message to a port. |
ping
:: Int -> Port a -> IO (Maybe Int)
Checks whether port p is still reachable. |
timeoutOnStream
:: Int -> [a] -> Maybe [a]
Checks for instantiation of a stream within some amount of time. |
openProcessPort
:: String -> IO (Port SP_Msg)
Opens a new connection to a process that executes a shell command. |
openNamedPort
:: String -> IO [a]
Opens an external port with a symbolic name. |
connectPortRepeat
:: Int -> IO a -> Int -> String -> IO (Maybe (Port b))
Waits for connection to an external port. |
connectPortWait
:: String -> IO (Port a)
Waits for connection to an external port and return the connected port. |
connectPort
:: String -> IO (Port a)
Connects to an external port. |
choiceSPEP
:: Port SP_Msg -> [a] -> Either String [a]
This function implements a committed choice over the receiving of messages via a stream port and an external port. |
newObject
:: (a -> [b] -> Bool) -> a -> Port b -> Bool
Creates a new object (of type State -> [msg] -> Bool )
with an initial state and a port to which messages for this object
can be sent.
|
newNamedObject
:: (a -> [b] -> Bool) -> a -> String -> IO ()
Creates a new object (of type State -> [msg] -> Bool )
with a symbolic port name to which messages for this object can be sent.
|
runNamedServer
:: ([a] -> IO b) -> String -> IO b
Runs a new server (of type [msg] -> IO a ) on a named port
to which messages can be sent.
|
The internal constructor for the port datatype is not visible to the user.
Constructors:
A "stream port" is an adaption of the port concept to model the communication with bidirectional streams, i.e., a stream port is a port connection to a bidirectional stream (e.g., opened by openProcessPort) where the communication is performed via the following stream port messages.
Constructors:
SP_Put
:: String -> SP_Msg
: write the argument s on the output stream
SP_GetLine
:: String -> SP_Msg
: unify the argument s with the next text line of the
input stream
SP_GetChar
:: Char -> SP_Msg
: unify the argument c with the next character of the
input stream
SP_EOF
:: Bool -> SP_Msg
: unify the argument b with True if we are at the end
of the input stream, otherwise with False
SP_Close
:: SP_Msg
: close the input/output streams
Opens an internal port for communication.
|
I/O action that sends a message to a port.
|
Checks whether port p is still reachable.
|
Checks for instantiation of a stream within some amount of time.
|
Opens a new connection to a process that executes a shell command.
|
Opens an external port with a symbolic name.
|
Waits for connection to an external port.
In contrast to
|
Waits for connection to an external port and return the connected port. This action waits (possibly forever) until the external port is registered.
|
Connects to an external port. The external port must be already registered, otherwise an error is reported.
|
This function implements a committed choice over the receiving of messages via a stream port and an external port. Note that the implementation of choiceSPEP works only with Sicstus-Prolog 3.8.5 or higher (due to a bug in previous versions of Sicstus-Prolog).
|
Creates a new object (of type
|
Creates a new object (of type
|
Runs a new server (of type
|