From 5350c9816949b2c1541c83d2c237868fa8f28eec Mon Sep 17 00:00:00 2001 From: Gregory Burd Date: Fri, 5 Jul 2013 11:04:14 -0400 Subject: [PATCH] Update Erlang glue to latest for async_nif as well. --- src/async_nif.hrl | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/async_nif.hrl b/src/async_nif.hrl index de4f592..9034d8a 100644 --- a/src/async_nif.hrl +++ b/src/async_nif.hrl @@ -1,32 +1,31 @@ -%% --------------------------------------------------------------------------- +%% ------------------------------------------------------------------- %% %% async_nif: An async thread-pool layer for Erlang's NIF API %% -%% Copyright (c) 2012-2013 Basho Technologies, Inc. All Rights Reserved. +%% Copyright (c) 2012 Basho Technologies, Inc. All Rights Reserved. %% Author: Gregory Burd %% -%% This file is provided to you under the Apache License, Version 2.0 (the -%% "License"); you may not use this file except in compliance with the License. -%% You may obtain a copy of the License at: +%% This file is provided to you under the Apache License, +%% Version 2.0 (the "License"); you may not use this file +%% except in compliance with the License. You may obtain +%% a copy of the License at %% %% http://www.apache.org/licenses/LICENSE-2.0 %% -%% Unless required by applicable law or agreed to in writing, software -%% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -%% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -%% License for the specific language governing permissions and limitations +%% Unless required by applicable law or agreed to in writing, +%% software distributed under the License is distributed on an +%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +%% KIND, either express or implied. See the License for the +%% specific language governing permissions and limitations %% under the License. %% -%% --------------------------------------------------------------------------- +%% ------------------------------------------------------------------- -spec async_nif_enqueue(reference(), function(), [term()]) -> term() | {error, term()}. async_nif_enqueue(R, F, A) -> case erlang:apply(F, [R|A]) of {ok, enqueued} -> receive - {R, {error, eagain}} -> - %% Work unit was not queued, try again. - async_nif_enqueue(R, F, A); {R, {error, shutdown}=Error} -> %% Work unit was queued, but not executed. Error; @@ -36,6 +35,11 @@ async_nif_enqueue(R, F, A) -> {R, Reply} -> Reply end; + {error, eagain} -> + %% Work unit was not queued, try again. + async_nif_enqueue(R, F, A); + %{error, enomem} -> + %{error, shutdown} -> Other -> Other end.