Copyright | (c) Parallel Scientific (Jeff Epstein) 2012 |
---|---|
License | BSD3 (see the file LICENSE) |
Safe Haskell | None |
Language | Haskell98 |
Maintainers : Jeff Epstein, Tim Watson Stability : experimental Portability : non-portable (requires concurrency)
This module provides a facility for Remote Procedure Call (rpc) style interactions with Cloud Haskell processes.
Clients make synchronous calls to a running process (i.e., server) using the
callAt
, callTimeout
and multicall
functions. Processes acting as the
server are constructed using Cloud Haskell's receive
family of primitives
and the callResponse
family of functions in this module.
- callAt :: (Serializable a, Serializable b) => ProcessId -> a -> Tag -> Process (Maybe b)
- callTimeout :: (Serializable a, Serializable b) => ProcessId -> a -> Tag -> Timeout -> Process (Maybe b)
- multicall :: forall a b. (Serializable a, Serializable b) => [ProcessId] -> a -> Tag -> Timeout -> Process [Maybe b]
- callResponse :: (Serializable a, Serializable b) => (a -> Process (b, c)) -> Match c
- callResponseIf :: (Serializable a, Serializable b) => (a -> Bool) -> (a -> Process (b, c)) -> Match c
- callResponseDefer :: (Serializable a, Serializable b) => (a -> (b -> Process ()) -> Process c) -> Match c
- callResponseDeferIf :: (Serializable a, Serializable b) => (a -> Bool) -> (a -> (b -> Process ()) -> Process c) -> Match c
- callForward :: Serializable a => (a -> (ProcessId, c)) -> Match c
- callResponseAsync :: (Serializable a, Serializable b) => (a -> Maybe c) -> (a -> Process b) -> Match c
Documentation
callAt :: (Serializable a, Serializable b) => ProcessId -> a -> Tag -> Process (Maybe b) Source
Like callTimeout
, but with no timeout.
Returns Nothing if the target process dies.
callTimeout :: (Serializable a, Serializable b) => ProcessId -> a -> Tag -> Timeout -> Process (Maybe b) Source
Sends a message of type a to the given process, to be handled by a corresponding callResponse... function, which will send back a message of type b. The tag is per-process unique identifier of the transaction. If the timeout expires or the target process dies, Nothing will be returned.
multicall :: forall a b. (Serializable a, Serializable b) => [ProcessId] -> a -> Tag -> Timeout -> Process [Maybe b] Source
Like callTimeout
, but sends the message to multiple
recipients and collects the results.
callResponse :: (Serializable a, Serializable b) => (a -> Process (b, c)) -> Match c Source
Produces a Match that can be used with the receiveWait
family of
message-receiving functions. callResponse
will respond to a message of
type a sent by callTimeout
, and will respond with a value of type b.
callResponseIf :: (Serializable a, Serializable b) => (a -> Bool) -> (a -> Process (b, c)) -> Match c Source
callResponseDefer :: (Serializable a, Serializable b) => (a -> (b -> Process ()) -> Process c) -> Match c Source
callResponseDeferIf :: (Serializable a, Serializable b) => (a -> Bool) -> (a -> (b -> Process ()) -> Process c) -> Match c Source
callForward :: Serializable a => (a -> (ProcessId, c)) -> Match c Source
Produces a Match that can be used with the receiveWait
family of
message-receiving functions. When calllForward receives a message of type
from from callTimeout
(and similar), it will forward the message to another
process, who will be responsible for responding to it. It is the user's
responsibility to ensure that the forwarding process is linked to the
destination process, so that if it fails, the sender will be notified.
callResponseAsync :: (Serializable a, Serializable b) => (a -> Maybe c) -> (a -> Process b) -> Match c Source
The message handling code is started in a separate thread. It's not automatically linked to the calling thread, so if you want it to be terminated when the message handling thread dies, you'll need to call link yourself.