A
Size: a a a
A
EK
EK
AK
EK
EK
DF
timer:
используется синглтон процесс, который менеджит все таймеры, поэтому он и является боттлнеком.DF
timer
module uses a separate process to manage the timers. That process can easily become overloaded if many processes create and cancel timers frequently (especially when using the SMP emulator).s
V
A
timer:
используется синглтон процесс, который менеджит все таймеры, поэтому он и является боттлнеком.DF
EK
V
A
timer_timeout(SysTime) ->
case ets:first(?TIMER_TAB) of
'$end_of_table' ->
infinity;
{Time, _Ref} when Time > SysTime ->
Timeout = (Time - SysTime + 999) div 1000,
%% Returned timeout must fit in a small int
erlang:min(Timeout, ?MAX_TIMEOUT);
Key ->
case ets:lookup(?TIMER_TAB, Key) of
[{Key, timeout, MFA}] ->
ets:delete(?TIMER_TAB,Key),
do_apply(MFA),
timer_timeout(SysTime);
[{{Time, Ref}, Repeat = {repeat, Interv, To}, MFA}] ->
ets:delete(?TIMER_TAB,Key),
NewTime = Time + Interv,
%% Update the interval entry (last in table)
ets:insert(?INTERVAL_TAB,{{interval,Ref},{NewTime,Ref},To}),
do_apply(MFA),
ets:insert(?TIMER_TAB, {{NewTime, Ref}, Repeat, MFA}),
timer_timeout(SysTime)
end
end.
V
DF
EK