Skip to content

Commit

Permalink
Replace stacktrace dependency with macro
Browse files Browse the repository at this point in the history
  • Loading branch information
David Leach committed Aug 13, 2018
1 parent 45386b0 commit ffe58ef
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
4 changes: 0 additions & 4 deletions rebar.config
Expand Up @@ -4,10 +4,6 @@
{parse_transform, stacktrace_transform}
]}.

{deps, [
{stacktrace_compat, "1.0.0"}
]}.

{eunit_opts, [verbose]}.
{cover_enabled, true}.

Expand Down
13 changes: 10 additions & 3 deletions src/poolboy.erl
Expand Up @@ -24,6 +24,14 @@
{global, GlobalName :: any()} |
{via, Module :: atom(), ViaName :: any()}.

-ifdef(OTP_RELEASE). %% this implies 21 or higher
-define(EXCEPTION(Class, Reason, Stacktrace), Class:Reason:Stacktrace).
-define(GET_STACK(Stacktrace), Stacktrace).
-else.
-define(EXCEPTION(Class, Reason, _), Class:Reason).
-define(GET_STACK(_), erlang:get_stacktrace()).
-endif.

% Copied from gen:start_ret/0
-type start_ret() :: {'ok', pid()} | 'ignore' | {'error', term()}.

Expand Down Expand Up @@ -84,10 +92,9 @@ checkout(Pool, Block, Timeout) ->
try
gen_server:call(Pool, {checkout, CRef, Block}, Timeout)
catch
Class:Reason ->
Stack = erlang:get_stacktrace(),
?EXCEPTION(Class, Reason, Stacktrace) ->
gen_server:cast(Pool, {cancel_waiting, CRef}),
erlang:raise(Class, Reason, Stack)
erlang:raise(Class, Reason, ?GET_STACK(Stacktrace))
end.

-spec checkin(Pool :: pool(), Worker :: pid()) -> ok.
Expand Down

0 comments on commit ffe58ef

Please sign in to comment.