From 5d40cc517edc9bb8ee70756544167b63f66662f0 Mon Sep 17 00:00:00 2001 From: getong Date: Sat, 14 Jul 2018 21:06:57 +0800 Subject: [PATCH] deprecated erlang:get_stacktrace/0 function --- src/poolboy.erl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/poolboy.erl b/src/poolboy.erl index db4973b..42c5085 100644 --- a/src/poolboy.erl +++ b/src/poolboy.erl @@ -18,6 +18,14 @@ -type pid_queue() :: queue:queue(). -endif. +-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. + -type pool() :: Name :: (atom() | pid()) | {Name :: atom(), node()} | @@ -54,9 +62,9 @@ checkout(Pool, Block, Timeout) -> try gen_server:call(Pool, {checkout, CRef, Block}, Timeout) catch - Class:Reason -> + ?EXCEPTION(Class, Reason, Stacktrace) -> gen_server:cast(Pool, {cancel_waiting, CRef}), - erlang:raise(Class, Reason, erlang:get_stacktrace()) + erlang:raise(Class, Reason, ?GET_STACK(Stacktrace)) end. -spec checkin(Pool :: pool(), Worker :: pid()) -> ok.