miniplex-0.3.4: simple 1-to-N interprocess communication

System.Miniplex

Contents

Description

Semisynchronous interprocess communication.

Synopsis

Documentation

Overview

This module provides interprocess communication channels. This is meant to be used by logger-like programs that want to send status reports to N listeners (where N >= 0).

Such a logger would create a Sink with a certain tag and just start writing messages to it. Then, at any point a client knowing the tag can attach a Source and receive those messages -- until it disconnects. This is all completely transparent to the logger.

Because each message is intended to be a complete status update, write does not buffer unsent messages: A client that is not ready to read when a new message arrives will simply skip it (and hopefully continue processing with the next message). However, there is one exception to this rule: A Sink remembers the last message sent and repeats it to newly connected clients. Therefore a client will always receive a message immediately after connecting unless the logger hasn't sent anything so far.

Implementation

The implementation is based on named sockets. Specifically, create "tag" creates the socket ~/.miniplex/tag. It also spawns a thread to watch it, which in turn spawns one thread per connected client. attach simply connects to this socket; no threads are spawned by System.Miniplex.Source.