diff options
author | Nathan Lasseter <Nathan Lasseter nathan@bytemark.co.uk> | 2014-05-30 13:34:17 +0100 |
---|---|---|
committer | Nathan Lasseter <Nathan Lasseter nathan@bytemark.co.uk> | 2014-05-30 13:34:17 +0100 |
commit | 08fecb93995728ab53d78beefc329331d79f303f (patch) | |
tree | 3ba80e9dede138ce108ad53183cecc47069c736e /eco_pool.erl | |
parent | 59cee25c7f863e76bc82cd58b33f6f3b4e13770c (diff) |
Added directory structure and Makefile
Diffstat (limited to 'eco_pool.erl')
-rw-r--r-- | eco_pool.erl | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/eco_pool.erl b/eco_pool.erl deleted file mode 100644 index 63fbc3d..0000000 --- a/eco_pool.erl +++ /dev/null @@ -1,42 +0,0 @@ --module(eco_pool). --export([start_pool/1, start_random_pool/2]). - -start_pool(Data) -> - pool_loop(Data). - -start_random_pool(Size, Max) -> - random:seed(now()), - Data = [random:uniform(Max) || _ <- lists:seq(1, Size)], - pool_loop(Data). - -pool_loop(PoolData) -> - receive - {From, stop} -> - From ! {ok, stopped}, - {ok, stopped}; - {From, drain} -> - From ! {ok, drained}, - pool_loop([]); - {From, set, Data} -> - From ! {ok, set, Data}, - pool_loop(Data); - {From, put, Data} -> - From ! {ok, put, Data}, - pool_loop(PoolData ++ Data); - {From, get, Data} -> - New = PoolData -- Data, - Test = PoolData -- New, - if - Test =:= Data -> - From ! {ok, get, Data}, - pool_loop(New); - true -> - From ! {error, get, Data}, - pool_loop(PoolData) - end; - {From, look} -> - From ! {ok, look, PoolData}, - pool_loop(PoolData); - Msg -> - {error, invalid_message, Msg} - end. |