example
start_link() ->
gen_server:start_link(locker,[],[]).
init([]) ->
{ok,[]}.
handle_call(request,Client,Pending)->
case Pending of
[] ->
{reply, ok, [Client]};
_ ->
{noreply, Pending ++ [Client]}
end;
handle_call(release, Client, [_|Pending]) ->
case Pending of
[] ->
{reply, done, []};
_ ->
gen_server:reply(hd(Pending), ok),
{reply, done, Pending}
end.
Föregående bild
Nästa bild
Tillbaka till första bilden
Visa grafisk version