Skip to content

Instantly share code, notes, and snippets.

@lpgauth
Created May 19, 2011 20:27
Show Gist options
  • Save lpgauth/981654 to your computer and use it in GitHub Desktop.
Save lpgauth/981654 to your computer and use it in GitHub Desktop.
%%--------------------------------------------------------------------
%%% Internal functions
%%--------------------------------------------------------------------
find_best_connection(Tid, Max_pipe) ->
case ets:first(Tid) of
{Cur_sz, Pid} when Cur_sz < Max_pipe ->
ets:delete(Tid, {Cur_sz, Pid}),
ets:insert(Tid, {{Cur_sz + 1, Pid}, []}),
{ok, Pid};
_ ->
{error, retry_later}
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment