Skip to content

Commit

Permalink
Convert to a pool of workers
Browse files Browse the repository at this point in the history
  • Loading branch information
ingwinlu committed Feb 6, 2016
1 parent 06e2b6d commit 048b996
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ PROJECT = wpool_broadcast
PROJECT_DESCRIPTION = New project
PROJECT_VERSION = 0.0.1

DEPS = worker_pool

# Whitespace to be used when creating files from templates.
SP = 4

Expand Down
14 changes: 11 additions & 3 deletions src/broadcast.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-behaviour(gen_server).

%% API.
-export([start_link/0, bump/1]).
-export([start_pool/0, bump/0, bump/1]).
%% gen_server.
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]).
Expand All @@ -13,8 +13,16 @@

%% API.

start_link() ->
gen_server:start_link(?MODULE, [], []).
start_pool() ->
wpool:start_pool(
?MODULE, [
{workers, 10},
{worker, {?MODULE, []}}
]
).

bump() ->
wpool:cast(?MODULE, bump).

bump(Pid) ->
gen_server:cast(Pid, bump).
Expand Down

0 comments on commit 048b996

Please sign in to comment.