Singleton: Difference between revisions

Content added Content deleted
No edit summary
Line 283: Line 283:
% spec singleton:get(Key::any()) -> {ok, Value::any()} | {error, not_found} | timeout
% spec singleton:get(Key::any()) -> {ok, Value::any()} | {error, not_found} | timeout
get(Key) ->
get(Key) ->
singleton() ! {get, self(), Key},
Pid = singleton(),
Pid ! {get, self(), Key},
receive
receive
{ok, Value} -> {ok, Value};
{ok, Value} -> {ok, Value};
Line 294: Line 293:
% spec singleton:set(Key::any(), Value::any()) -> ok | timeout
% spec singleton:set(Key::any(), Value::any()) -> ok | timeout
set(Key, Value) ->
set(Key, Value) ->
singleton() ! {set, self(), Key, Value},
Pid = singleton(),
Pid ! {set, self(), Key, Value},
receive
receive
ok -> ok;
ok -> ok;