class Earl::Registry(A, M)

Overview

A concurrency-safe registry of agents.

Concurrency

Relies on a copy-on-write array:

This assumes that agents will (un)register themselves infrequently and messages be sent much more often.

Defined in:

registry.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new #

[View source]

Instance Method Detail

def closed? : Bool #

[View source]
def each(&) : Nil #

Iterates registered agents. Always iterates agents registered at the moment the iteration is started. Newly registered agents won't be iterated, when newly unregistered agents will be.


[View source]
def register(agent : A) : Nil #

Registers an agent. Raises if the registry is closed.


[View source]
def send(message : M) : Nil #

Broadcasts a message to all registered agents at the time


[View source]
def stop : Nil #

Closes the registry, preventing agents to register, then asks all registered agents to stop.


[View source]
def unregister(agent : A) : Nil #

Unregisters an agent.


[View source]