aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter/src/base/diameter_stats.erl
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2015-08-13 17:08:15 +0200
committerAnders Svensson <[email protected]>2015-08-13 23:01:28 +0200
commit8c5d719afaeae0c9cfa1079c0de5452f8bdc837b (patch)
treec886baae9730405c7dafac7549e9a1246aac686a /lib/diameter/src/base/diameter_stats.erl
parentc972a98fe58569d661e9bfad5512bcdb498f6200 (diff)
parent155c22ff3ce3f667d4a984bd6648f029e0998381 (diff)
downloadotp-8c5d719afaeae0c9cfa1079c0de5452f8bdc837b.tar.gz
otp-8c5d719afaeae0c9cfa1079c0de5452f8bdc837b.tar.bz2
otp-8c5d719afaeae0c9cfa1079c0de5452f8bdc837b.zip
Merge branch 'maint-17' into maint
The diffs are all about adapting to the OTP 18 time interface. The code was previously backwards compatible, falling back on the erlang:now/0 if erlang:monotonic_time/0 is unavailable, but this was seen to be a bad thing in commit 9c0f2f2c. Use of erlang:now/0 is now removed.
Diffstat (limited to 'lib/diameter/src/base/diameter_stats.erl')
-rw-r--r--lib/diameter/src/base/diameter_stats.erl18
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/diameter/src/base/diameter_stats.erl b/lib/diameter/src/base/diameter_stats.erl
index 83e562e7fe..8c10464e98 100644
--- a/lib/diameter/src/base/diameter_stats.erl
+++ b/lib/diameter/src/base/diameter_stats.erl
@@ -25,9 +25,6 @@
-module(diameter_stats).
-behaviour(gen_server).
--compile({no_auto_import, [now/0]}).
--import(diameter_lib, [now/0]).
-
-export([reg/2, reg/1,
incr/3, incr/1,
read/1,
@@ -61,7 +58,7 @@
-define(SERVER, ?MODULE).
%% Server state.
--record(state, {id = now()}).
+-record(state, {id = diameter_lib:now()}).
-type counter() :: any().
-type ref() :: any().
@@ -143,9 +140,14 @@ read(Refs, B) ->
L.
to_refdict(L) ->
- lists:foldl(fun({{C,R}, N}, D) -> orddict:append(R, {C,N}, D) end,
- orddict:new(),
- L).
+ lists:foldl(fun append/2, orddict:new(), L).
+
+%% Order both references and counters in the returned list.
+append({{Ctr, Ref}, N}, Dict) ->
+ orddict:update(Ref,
+ fun(D) -> orddict:store(Ctr, N, D) end,
+ [{Ctr, N}],
+ Dict).
%% ---------------------------------------------------------------------------
%% # sum(Refs)
@@ -221,7 +223,7 @@ uptime() ->
%% ----------------------------------------------------------
init([]) ->
- ets:new(?TABLE, [named_table, ordered_set, public]),
+ ets:new(?TABLE, [named_table, set, public, {write_concurrency, true}]),
{ok, #state{}}.
%% ----------------------------------------------------------