Refactor: rename 'tick_tref' field to 'ticker'

This commit is contained in:
Feng Lee 2017-06-16 16:01:27 +08:00
parent adfd34852b
commit 1e205720cc
1 changed files with 5 additions and 5 deletions

View File

@ -40,7 +40,7 @@
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, -export([init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]). terminate/2, code_change/3]).
-record(state, {started_at, sys_interval, heartbeat, tick_tref, version, sysdescr}). -record(state, {started_at, sys_interval, heartbeat, ticker, version, sysdescr}).
-define(APP, emqttd). -define(APP, emqttd).
@ -122,9 +122,9 @@ init([]) ->
% Tick % Tick
{ok, #state{started_at = os:timestamp(), {ok, #state{started_at = os:timestamp(),
heartbeat = start_tick(1000, heartbeat), heartbeat = start_tick(1000, heartbeat),
version = list_to_binary(version()), version = list_to_binary(version()),
sysdescr = list_to_binary(sysdescr()), sysdescr = list_to_binary(sysdescr()),
tick_tref = start_tick(tick)}, hibernate}. ticker = start_tick(tick)}, hibernate}.
handle_call(uptime, _From, State) -> handle_call(uptime, _From, State) ->
{reply, uptime(State), State}; {reply, uptime(State), State};
@ -149,7 +149,7 @@ handle_info(tick, State = #state{version = Version, sysdescr = Descr}) ->
handle_info(Info, State) -> handle_info(Info, State) ->
?UNEXPECTED_INFO(Info, State). ?UNEXPECTED_INFO(Info, State).
terminate(_Reason, #state{heartbeat = Hb, tick_tref = TRef}) -> terminate(_Reason, #state{heartbeat = Hb, ticker = TRef}) ->
stop_tick(Hb), stop_tick(Hb),
stop_tick(TRef), stop_tick(TRef),
ok. ok.