diff options
Diffstat (limited to 'src/cowboy_clock.erl')
-rw-r--r-- | src/cowboy_clock.erl | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/cowboy_clock.erl b/src/cowboy_clock.erl index a7645d9..cc824ed 100644 --- a/src/cowboy_clock.erl +++ b/src/cowboy_clock.erl @@ -60,6 +60,7 @@ rfc1123() -> %% gen_server. +-spec init([]) -> {ok, #state{}}. init([]) -> ?TABLE = ets:new(?TABLE, [set, protected, named_table, {read_concurrency, true}]), @@ -69,28 +70,32 @@ init([]) -> ets:insert(?TABLE, {rfc1123, B}), {ok, #state{universaltime=T, rfc1123=B, tref=TRef}}. +-spec handle_call(_, _, State) + -> {reply, ignored, State} | {stop, normal, stopped, State}. handle_call(stop, _From, State=#state{tref=TRef}) -> {ok, cancel} = timer:cancel(TRef), {stop, normal, stopped, State}; - handle_call(_Request, _From, State) -> {reply, ignored, State}. +-spec handle_cast(_, State) -> {noreply, State}. handle_cast(_Msg, State) -> {noreply, State}. +-spec handle_info(_, State) -> {noreply, State}. handle_info(update, #state{universaltime=Prev, rfc1123=B1, tref=TRef}) -> T = erlang:universaltime(), B2 = update_rfc1123(B1, Prev, T), ets:insert(?TABLE, {rfc1123, B2}), {noreply, #state{universaltime=T, rfc1123=B2, tref=TRef}}; - handle_info(_Info, State) -> {noreply, State}. +-spec terminate(_, _) -> ok. terminate(_Reason, _State) -> ok. +-spec code_change(_, State, _) -> {ok, State}. code_change(_OldVsn, State, _Extra) -> {ok, State}. |