diff options
author | Sverker Eriksson <[email protected]> | 2018-11-22 15:52:13 +0100 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2018-11-22 15:52:13 +0100 |
commit | fb8018f9ebebbcb5ef074e33514a4c03aaefbe2d (patch) | |
tree | 01dc57e92e043916c611cf9c814fe9102cc9a81f /erts/preloaded/src/counters.erl | |
parent | e0cfc10e85515823cdd8343919dfaeb1884dc0a4 (diff) | |
parent | f504781a136b1992a1cee26a7da841892d796d91 (diff) | |
download | otp-fb8018f9ebebbcb5ef074e33514a4c03aaefbe2d.tar.gz otp-fb8018f9ebebbcb5ef074e33514a4c03aaefbe2d.tar.bz2 otp-fb8018f9ebebbcb5ef074e33514a4c03aaefbe2d.zip |
Merge branch 'sverker/erts/atomics-counters/OTP-13468' into maint
AGAIN
* sverker/erts/atomics-counters/OTP-13468:
erts: Add counters:put/3
Diffstat (limited to 'erts/preloaded/src/counters.erl')
-rw-r--r-- | erts/preloaded/src/counters.erl | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/erts/preloaded/src/counters.erl b/erts/preloaded/src/counters.erl index 67354f648d..a0e3035e0f 100644 --- a/erts/preloaded/src/counters.erl +++ b/erts/preloaded/src/counters.erl @@ -26,6 +26,7 @@ get/2, add/3, sub/3, + put/3, info/1]). -export_type([counters_ref/0]). @@ -76,6 +77,19 @@ add(_, _, _) -> sub(Ref, Ix, Decr) -> add(Ref, Ix, -Decr). + +-spec put(Ref, Ix, Value) -> ok when + Ref :: counters_ref(), + Ix :: integer(), + Value :: integer(). +put({atomics, Ref}, Ix, Value) -> + atomics:put(Ref, Ix, Value); +put({write_concurrency, Ref}, Ix, Value) -> + erts_internal:counters_put(Ref, Ix, Value); +put(_, _, _) -> + erlang:error(badarg). + + -spec info(Ref) -> Info when Ref :: counters_ref(), Info :: #{'size':=Size, 'memory':=Memory}, |