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 96d43d5d17

View file

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