Skip to content

Commit

Permalink
Merge pull request #15 from ferd/otp-18-compat
Browse files Browse the repository at this point in the history
Erlang 18.0+ compatibility
  • Loading branch information
tsloughter committed Jul 16, 2015
2 parents 0d440de + aa54c1c commit 8ec1aa2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
language: erlang
otp_release:
- 18.0
- 17.5
- R16B
- R15B02
- R15B01
Expand Down
15 changes: 12 additions & 3 deletions src/epna_pool.erl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
%%% Types
%%%===================================================================

-type state() :: record(state).
-type state() :: #state{}.

%%%===================================================================
%%% API
Expand Down Expand Up @@ -284,8 +284,17 @@ cleanup_connection(C, State = #state{working=Working}) ->
%% Return the current time in seconds, used for timeouts.
-spec now_secs() -> non_neg_integer().
now_secs() ->
{M,S,_M} = erlang:now(),
M*1000 + S.
try
%% use apply/3 because otherwise cover compilation
%% fails on < 18.0
apply(erlang, monotonic_time, [seconds])
catch
error:undef ->
%% use apply/3 because otherwise the compiler
%% warns in 18.0+
{M,S,_M} = apply(erlang, now, []),
M*1000 + S
end.

-spec make_registered_name(episcina:name()) -> term().
make_registered_name(Name) ->
Expand Down

0 comments on commit 8ec1aa2

Please sign in to comment.