capataz-0.1.0.0: OTP-like supervision trees in Haskell

Safe HaskellNone
LanguageHaskell2010

Control.Concurrent.Capataz.Internal.Util

Description

This module contains:

  • Functions to manipulate the state of the Supervisor record
  • Utility functions used for communication between threads
  • Public API utility functions

Synopsis

Documentation

getTidNumber :: ThreadId -> Maybe Text Source #

Returns only the number of the ThreadId.

setProcessThreadName :: WorkerId -> WorkerName -> IO () Source #

Internal functions that overwrites the GHC thread name, for increasing traceability on GHC internals.

getProcessId :: Process -> ProcessId Source #

Gets the ProcessId of both a Worker or Supervisor process.

fetchProcess :: SupervisorEnv -> ProcessId -> IO (Maybe Process) Source #

Gets a supervised Process from a Supervisor instance.

appendProcessToMap :: SupervisorEnv -> Process -> IO () Source #

Appends a new Process to the Supervisor existing process map.

removeProcessFromMap :: SupervisorEnv -> ProcessId -> IO () Source #

Removes a Process from a Supervisor existing process map.

resetProcessMap :: SupervisorEnv -> (ProcessMap -> ProcessMap) -> IO () Source #

Function to modify a Supervisor process map using a pure function.

readProcessMap :: SupervisorEnv -> IO ProcessMap Source #

Function to get a snapshot of a Supervisor process map.

sortProcessesByTerminationOrder :: ProcessTerminationOrder -> ProcessMap -> [Process] Source #

Returns all processes of a Supervisor by ProcessTerminationOrder. This is used on AllForOne restarts and shutdown operations.

readSupervisorStatusSTM :: TVar SupervisorStatus -> STM SupervisorStatus Source #

Returns the SupervisorStatus, this sub-routine will retry transaction until its associated Supervisor has a status different from Initializing.

readSupervisorStatus :: SupervisorEnv -> IO SupervisorStatus Source #

Executes transaction that returns the SupervisorStatus.

writeSupervisorStatus :: SupervisorEnv -> SupervisorStatus -> IO () Source #

Modifes the Supervisor status.

IMPORTANT: this is the only function that should be used for this purpose given it has the side-effect of notifying a status change via the "notifyEvent" sub-routine, orginally given in the CapatazOption record.

sendControlMsg :: SupervisorEnv -> ControlAction -> IO () Source #

Used from public API functions to send ControlAction messages to a Supervisor thread loop.

sendSyncControlMsg Source #

Arguments

:: SupervisorEnv 
-> (IO () -> ControlAction)

Blocking sub-routine used from the caller

-> IO () 

Used from public API functions to send ControlAction messages to the a Supervisor thread loop, it receives an IO sub-routine that expects an IO operation that blocks a thread until the message is done.

toParentSupervisorEnv :: SupervisorEnv -> ParentSupervisorEnv Source #

Utility function to transform a SupervisorEnv record to a ParentSupervisorEnv record; used on functions where supervision of supervisors is managed.