| Safe Haskell | None |
|---|
LogicGrowsOnTrees.Parallel.Common.Message
Description
This module contains infrastructure for communicating with workers over an inter-process channel.
- data MessageForSupervisor progress worker_final_progress
- = Failed String
- | Finished worker_final_progress
- | ProgressUpdate (ProgressUpdate progress)
- | StolenWorkload (Maybe (StolenWorkload progress))
- | WorkerQuit
- type MessageForSupervisorFor exploration_mode = MessageForSupervisor (ProgressFor exploration_mode) (WorkerFinishedProgressFor exploration_mode)
- data MessageForSupervisorReceivers exploration_mode worker_id = MessageForSupervisorReceivers {
- receiveProgressUpdateFromWorker :: worker_id -> ProgressUpdate (ProgressFor exploration_mode) -> IO ()
- receiveStolenWorkloadFromWorker :: worker_id -> Maybe (StolenWorkload (ProgressFor exploration_mode)) -> IO ()
- receiveFailureFromWorker :: worker_id -> String -> IO ()
- receiveFinishedFromWorker :: worker_id -> WorkerFinishedProgressFor exploration_mode -> IO ()
- receiveQuitFromWorker :: worker_id -> IO ()
- data MessageForWorker
- receiveAndProcessMessagesFromWorker :: MessageForSupervisorReceivers exploration_mode worker_id -> IO (MessageForSupervisorFor exploration_mode) -> worker_id -> IO ()
- receiveAndProcessMessagesFromWorkerUsingHandle :: (Serialize (ProgressFor exploration_mode), Serialize (WorkerFinishedProgressFor exploration_mode)) => MessageForSupervisorReceivers exploration_mode worker_id -> Handle -> worker_id -> IO ()
Types
data MessageForSupervisor progress worker_final_progress Source
A message from a worker to the supervisor; the worker id is assumed to be known based on from where the message was received.
Constructors
| Failed String | The worker encountered a failure with the given message while exploring the tree. |
| Finished worker_final_progress | The worker has finished with the given final progress. |
| ProgressUpdate (ProgressUpdate progress) | The worker has responded to the progress update request with the given progress update. |
| StolenWorkload (Maybe (StolenWorkload progress)) | The worker has responded to the workload steal request with possibly the stolen workload (and |
| WorkerQuit | The worker has quit the system and is no longer available |
Instances
| (Eq progress, Eq worker_final_progress) => Eq (MessageForSupervisor progress worker_final_progress) | |
| (Show progress, Show worker_final_progress) => Show (MessageForSupervisor progress worker_final_progress) | |
| (Serialize progress_1627556287, Serialize worker_final_progress_1627556288) => Serialize (MessageForSupervisor progress_1627556287 worker_final_progress_1627556288) |
type MessageForSupervisorFor exploration_mode = MessageForSupervisor (ProgressFor exploration_mode) (WorkerFinishedProgressFor exploration_mode)Source
Convenient type alias for the MessageForSupervisor type for the given exploration mode.
data MessageForSupervisorReceivers exploration_mode worker_id Source
This data structure contains callbacks to be invoked when a message has been received, depending on the kind of message.
Constructors
| MessageForSupervisorReceivers | |
Fields
| |
data MessageForWorker Source
A message from the supervisor to a worker.
NOTE: It is your responsibility not to send a workload to a worker that already has one; if you do then the worker will report an error and then terminate. The converse, however, is not true: it is okay to send a progress request to a worker without a workload because the worker might have finished between when you sent the message and when it was received.
Constructors
| RequestProgressUpdate | request a progress update |
| RequestWorkloadSteal | request a stolen workload |
| StartWorkload Workload | start exploring the given workload |
| QuitWorker | stop what you are doing and quit the system |
Functions
receiveAndProcessMessagesFromWorkerSource
Arguments
| :: MessageForSupervisorReceivers exploration_mode worker_id | the callbacks to invoke when a message has been received |
| -> IO (MessageForSupervisorFor exploration_mode) | an action that fetches the next message |
| -> worker_id | the id of the worker from which messages are being received |
| -> IO () | an IO action that continually processes incoming messages from a worker until it quits, at which point it returns |
Continually performs the given IO action to read a message from a worker with the given id and calls one of the given callbacks depending on the content of the message.
receiveAndProcessMessagesFromWorkerUsingHandleSource
Arguments
| :: (Serialize (ProgressFor exploration_mode), Serialize (WorkerFinishedProgressFor exploration_mode)) | |
| => MessageForSupervisorReceivers exploration_mode worker_id | the callbacks to invoke when a message has been received |
| -> Handle | the handle from which messages should be read |
| -> worker_id | the id of the worker from which messages are being received |
| -> IO () | an IO action that continually processes incoming messages from a worker until it quits, at which point it returns |
The same as receiveAndProcessMessagesFromWorker except that instead of
giving it an IO action to fetch a message you provide a Handle from which
messsages (assumed to be deserializable) are read.