Module evel_name

An evel based global name registration facility.

Copyright © 2016 Takeru Ohta <phjgt308@gmail.com> This software is released under the MIT License. See the LICENSE file in the project root for full license information.

Description

An evel based global name registration facility

This module is available as a via callback module for OTP behaviours (e.g., supervisor, gen_server, etc).

  %%
  %% Example
  %%
  gen_server:start_link({via, evel_name, SomeName}, ?MODULE, [], []).

Data Types

name()

name() = term()

A name of the process

Function Index

register_name/2Globally associates the name Name with a pid Pid
send/2Sends the message Message to the pid globally registered as Name
unregister_name/1Removes the globally registered name Name
whereis_name/1Returns the pid with the globally registered name Name

Function Details

register_name/2

register_name(Name::name(), Pid::pid()) -> yes | no

Globally associates the name Name with a pid Pid

The function returns yes if successful, no if it fails. For example, no is returned if an attempt is made to register a process with a name that is already in use.

Unlike global:register_name/1, this function allows a process to have multiple names.

If conlict arises between multiple processes during a registration, only one process survive.

send/2

send(Name::name(), Message::term()) -> pid()

Sends the message Message to the pid globally registered as Name

Failure: If Name is not a registered name, the calling function will exit with reason {badarg, {Name, Message}}

unregister_name/1

unregister_name(Name::name()) -> ok

Removes the globally registered name Name

whereis_name/1

whereis_name(Name::name()) -> pid() | undefined

Returns the pid with the globally registered name Name

Returns undefined if the name is not registered.


Generated by EDoc, Oct 29 2017, 01:52:16.