Copyright | (c) Pierre-Étienne Meunier 2014 |
---|---|
License | GPL-3 |
Maintainer | pierre-etienne.meunier@lif.univ-mrs.fr |
Stability | experimental |
Portability | All |
Safe Haskell | None |
Language | Haskell2010 |
Tools to build synchronization servers. For instance, to write a simple server with just a web interface on port 8000, you would use:
import Control.Concurrent import Parry.Server import Parry.WebUI main::IO () main=do state<-initState initial _<-forkIO $ webUI 8000 state server (defaultConfig public) state
- class Exhaustive j where
- class Result j r where
- initState :: (Exhaustive j, Ord j, Result j r) => [j] -> r -> IO (MVar (State j r))
- stateFromFile :: (Binary r, Binary j, Exhaustive j, Result j r, Ord j) => FilePath -> [j] -> r -> IO (MVar (State j r))
- saveThread :: (Binary r, Binary j) => FilePath -> Int -> MVar (State j r) -> IO ()
- data State j r = State {}
- data Config = Config {}
- defaultConfig :: Config
- server :: (Ord j, Binary j, Exhaustive j, Result j r) => Config -> MVar (State j r) -> IO ()
Jobs on the server side
class Exhaustive j where Source
The class of jobs and job results that Parry can deal with. For efficiency and to keep types simple, jobs and results are stored in a single type.
Indication of the depth of a job in the explored tree. The server sends the least deep jobs first, as an optimization of network use.
Number of times a job has been killed. When a job is killed, either because it must be reshared, or because the client itself was killed, it is scheduled to be re-executed by the server.
Called each time a job needs to be killed. For better resharing,
this function must verify killed (kill j) >= killed j
.
The class of results, and how to combine them in the server state.
Server's internal state
initState :: (Exhaustive j, Ord j, Result j r) => [j] -> r -> IO (MVar (State j r)) Source
Creates a valid server state from an initial job.
stateFromFile :: (Binary r, Binary j, Exhaustive j, Result j r, Ord j) => FilePath -> [j] -> r -> IO (MVar (State j r)) Source
Reads initial state from a file, or calls initState
if the file does
not exist.
saveThread :: (Binary r, Binary j) => FilePath -> Int -> MVar (State j r) -> IO () Source
Saves state to the given file with the given periodicity, in
microseconds. This function does not return, so calling it inside a
forkIO
is probably the best thing to do.
This type is exposed mostly for writing alternative user interfaces. Other operations must be done using the functions in this module, or the correction of the protocol can be lost.
State | |
|
Server configuration and functions
Server configuration
defaultConfig :: Config Source
Default server configuration, matching the client. Note that you must provide your own public key for signing the messages.