LogicGrowsOnTrees-1.0.0.0.1: a parallel implementation of logic programming using distributed tree exploration

Safe HaskellNone

LogicGrowsOnTrees.Parallel.Common.Message

Contents

Description

This module contains infrastructure for communicating with workers over an inter-process channel.

Synopsis

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 Nothing if it was not possible to steal a workload at this time).

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_1627715877, Serialize worker_final_progress_1627715878) => Serialize (MessageForSupervisor progress_1627715877 worker_final_progress_1627715878) 

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

receiveProgressUpdateFromWorker :: worker_id -> ProgressUpdate (ProgressFor exploration_mode) -> IO ()

to be called when a progress update has been received from a worker

receiveStolenWorkloadFromWorker :: worker_id -> Maybe (StolenWorkload (ProgressFor exploration_mode)) -> IO ()

to be called when a (possibly) stolen workload has been received from a worker

receiveFailureFromWorker :: worker_id -> String -> IO ()

to be called when a failure (with the given message) has been received from a worker

receiveFinishedFromWorker :: worker_id -> WorkerFinishedProgressFor exploration_mode -> IO ()

to be called when a worker has finished with the given final progress

receiveQuitFromWorker :: worker_id -> IO ()

to be called when a worker has quit the system and is no longer available

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.