Skip to content
Browse files

Dialyzer optimizations for newer Erlang releases

  • Loading branch information...
1 parent c2c939b commit ae05fd35dcfa095a7e9538a9d8f8297ba4638eab @drobakowski drobakowski committed Jan 9, 2014
Showing with 23 additions and 0 deletions.
  1. +10 −0 rebar.config.script
  2. +13 −0 src/poolboy_worker.erl
View
10 rebar.config.script
@@ -0,0 +1,10 @@
+{match, [ErtsNumber]} = re:run(erlang:system_info(otp_release), "R(\\d+).+", [{capture, [1], list}]),
+ErtsVsn = erlang:list_to_integer(ErtsNumber),
+if
+ ErtsVsn >= 15 ->
+ OldOpts = proplists:get_value(erl_opts, CONFIG, []),
+ NewOpts = [{d, have_callback_support} | OldOpts],
+ lists:keystore(erl_opts, 1, CONFIG, {erl_opts, NewOpts});
+ true ->
+ CONFIG
+end.
View
13 src/poolboy_worker.erl
@@ -2,9 +2,22 @@
-module(poolboy_worker).
+-ifdef(have_callback_support).
+
+-callback start_link(WorkerArgs) -> {ok, Pid} |
+ {error, {already_started, Pid}} |
+ {error, Reason} when
+ WorkerArgs :: proplists:proplist(),
+ Pid :: pid(),
+ Reason :: term().
+
+-else.
+
-export([behaviour_info/1]).
behaviour_info(callbacks) ->
[{start_link, 1}];
behaviour_info(_Other) ->
undefined.
+
+-endif.

0 comments on commit ae05fd3

Please sign in to comment.
Something went wrong with that request. Please try again.