Integrate newest version which avoids the need for a seperate fun.
This commit is contained in:
parent
6d5daab80d
commit
095031a23d
1 changed files with 24 additions and 24 deletions
|
@ -21,9 +21,10 @@
|
||||||
%%
|
%%
|
||||||
%% -------------------------------------------------------------------
|
%% -------------------------------------------------------------------
|
||||||
|
|
||||||
-spec async_nif_enqueue(reference(), function(), [term()]) -> term() | {error, term()}.
|
-define(ASYNC_NIF_CALL(Fun, Args),
|
||||||
async_nif_enqueue(R, F, A) ->
|
F = fun(F, T) ->
|
||||||
case erlang:apply(F, [R|A]) of
|
R = erlang:make_ref(),
|
||||||
|
case erlang:apply(F, [R|Args]) of
|
||||||
{ok, enqueued} ->
|
{ok, enqueued} ->
|
||||||
receive
|
receive
|
||||||
{R, {error, shutdown}=Error} ->
|
{R, {error, shutdown}=Error} ->
|
||||||
|
@ -36,12 +37,11 @@ async_nif_enqueue(R, F, A) ->
|
||||||
Reply
|
Reply
|
||||||
end;
|
end;
|
||||||
{error, eagain} ->
|
{error, eagain} ->
|
||||||
%% Work unit was not queued, try again.
|
SleepyTime = min(30, (T+1)*2),
|
||||||
async_nif_enqueue(R, F, A);
|
timer:sleep(SleepyTime),
|
||||||
%{error, enomem} ->
|
F(F, SleepyTime);
|
||||||
%{error, shutdown} ->
|
|
||||||
Other ->
|
Other ->
|
||||||
Other
|
Other
|
||||||
end.
|
end
|
||||||
|
end,
|
||||||
-define(ASYNC_NIF_CALL(Fun, Args), async_nif_enqueue(erlang:make_ref(), Fun, Args)).
|
F(Fun, 0)).
|
||||||
|
|
Loading…
Reference in a new issue