Re-use the unchanging value of 'Args' rather than including it in every recursive call.

This commit is contained in:
Gregory Burd 2013-08-02 14:18:19 -04:00
parent 05c8c615ef
commit 6919515de5

View file

@ -22,9 +22,9 @@
%% ------------------------------------------------------------------- %% -------------------------------------------------------------------
-define(ASYNC_NIF_CALL(Fun, Args), -define(ASYNC_NIF_CALL(Fun, Args),
F = fun(F, A, T) -> F = fun(F, T) ->
R = erlang:make_ref(), R = erlang:make_ref(),
case erlang:apply(F, [R|A]) of case erlang:apply(F, [R|Args]) of
{ok, enqueued} -> {ok, enqueued} ->
receive receive
{R, {error, shutdown}=Error} -> {R, {error, shutdown}=Error} ->
@ -39,9 +39,9 @@
{error, eagain} -> {error, eagain} ->
SleepyTime = min(30, (T+1)*2), SleepyTime = min(30, (T+1)*2),
timer:sleep(SleepyTime), timer:sleep(SleepyTime),
F(F, A, SleepyTime); F(F, SleepyTime);
Other -> Other ->
Other Other
end end
end, end,
F(Fun, Args, 0)). F(Fun, 0)).