Browse Source

forgot to actually add the bcast modules

Ulf Wiger 13 years ago
parent
commit
62ac4396bf
2 changed files with 143 additions and 0 deletions
  1. 82 0
      doc/gproc_bcast.md
  2. 61 0
      src/gproc_bcast.erl

+ 82 - 0
doc/gproc_bcast.md

@@ -0,0 +1,82 @@
+
+
+#Module gproc_bcast#
+* [Description](#description)
+* [Function Index](#index)
+* [Function Details](#functions)
+
+
+Gproc message broadcast server
+This module is used to support gproc:bcast(Key, Msg).
+
+__Behaviours:__ [`gen_server`](gen_server.md).
+
+__Authors:__ Ulf Wiger ([`ulf@wiger.net`](mailto:ulf@wiger.net)).<a name="description"></a>
+
+##Description##
+
+
+gproc:bcast/2 allows for e.g. distributed publish/subscribe, without
+having to resort to global property registration.
+To ensure that erlang's message ordering guarantees are kept, all sends
+are channeled through a broadcast server on each node.<a name="index"></a>
+
+##Function Index##
+
+
+<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#code_change-3">code_change/3</a></td><td></td></tr><tr><td valign="top"><a href="#handle_call-3">handle_call/3</a></td><td></td></tr><tr><td valign="top"><a href="#handle_cast-2">handle_cast/2</a></td><td></td></tr><tr><td valign="top"><a href="#handle_info-2">handle_info/2</a></td><td></td></tr><tr><td valign="top"><a href="#init-1">init/1</a></td><td></td></tr><tr><td valign="top"><a href="#start_link-0">start_link/0</a></td><td></td></tr><tr><td valign="top"><a href="#terminate-2">terminate/2</a></td><td></td></tr></table>
+
+
+<a name="functions"></a>
+
+##Function Details##
+
+<a name="code_change-3"></a>
+
+###code_change/3##
+
+
+`code_change(X1, S, X3) -> any()`
+
+<a name="handle_call-3"></a>
+
+###handle_call/3##
+
+
+`handle_call(X1, X2, S) -> any()`
+
+<a name="handle_cast-2"></a>
+
+###handle_cast/2##
+
+
+`handle_cast(X1, S) -> any()`
+
+<a name="handle_info-2"></a>
+
+###handle_info/2##
+
+
+`handle_info(X1, S) -> any()`
+
+<a name="init-1"></a>
+
+###init/1##
+
+
+`init(X1) -> any()`
+
+<a name="start_link-0"></a>
+
+###start_link/0##
+
+
+`start_link() -> any()`
+
+<a name="terminate-2"></a>
+
+###terminate/2##
+
+
+`terminate(X1, X2) -> any()`
+

+ 61 - 0
src/gproc_bcast.erl

@@ -0,0 +1,61 @@
+%% ``The contents of this file are subject to the Erlang Public License,
+%% Version 1.1, (the "License"); you may not use this file except in
+%% compliance with the License. You should have received a copy of the
+%% Erlang Public License along with this software. If not, it can be
+%% retrieved via the world wide web at http://www.erlang.org/.
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%% the License for the specific language governing rights and limitations
+%% under the License.
+%%
+%% The Initial Developer of the Original Code is Ericsson Utvecklings AB.
+%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings
+%% AB. All Rights Reserved.''
+%%
+%% @author Ulf Wiger <ulf@wiger.net>
+%%
+%% @doc Gproc message broadcast server
+%% This module is used to support gproc:bcast(Key, Msg).
+%%
+%% gproc:bcast/2 allows for e.g. distributed publish/subscribe, without
+%% having to resort to global property registration.
+%% To ensure that erlang's message ordering guarantees are kept, all sends
+%% are channeled through a broadcast server on each node.
+%% @end
+
+-module(gproc_bcast).
+-behaviour(gen_server).
+
+-export([start_link/0,
+	 init/1,
+	 handle_cast/2,
+	 handle_call/3,
+	 handle_info/2,
+	 terminate/2,
+	 code_change/3]).
+
+start_link() ->
+    gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
+
+init([]) ->
+    {ok, []}.
+
+handle_call(_, _, S) ->
+    {reply, {error, unknown_call}, S}.
+
+handle_cast({send, Key, Msg}, S) ->
+    catch gproc:send(Key, Msg),
+    {noreply, S};
+handle_cast(_, S) ->
+    {noreply, S}.
+
+handle_info(_, S) ->
+    {noreply, S}.
+
+terminate(_, _) ->
+    ok.
+
+code_change(_, S, _) ->
+    {ok, S}.
+