File 0003-redo_concurrency_test-using-module-rand-for-Erlang-O.patch of Package redo
From 63d89bb4f32947a4fea2aa341a247911cd94d564 Mon Sep 17 00:00:00 2001
From: Led <ledest@gmail.com>
Date: Sun, 25 Jun 2017 01:02:14 +0300
Subject: [PATCH 3/3] redo_concurrency_test: using module rand for Erlang/OTP
>= 18
---
src/redo_concurrency_test.erl | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/redo_concurrency_test.erl b/src/redo_concurrency_test.erl
index eaa819a..293fab9 100644
--- a/src/redo_concurrency_test.erl
+++ b/src/redo_concurrency_test.erl
@@ -49,10 +49,10 @@ worker(Parent, N, 0) ->
Parent ! {self(), N, done};
worker(Parent, N, NumOps) ->
- random:seed(os:timestamp()),
+ seed(),
StrN = integer_to_list(N),
StrOp = integer_to_list(NumOps),
- case random:uniform(100) of
+ case uniform(100) of
R when R > 0, R =< 24 ->
Key = iolist_to_binary([StrN, ":", StrOp, ":STRING"]),
Val = iolist_to_binary(["STRING:", StrN, ":", StrOp]),
@@ -104,3 +104,11 @@ worker(Parent, N, NumOps) ->
end,
worker(Parent, N, NumOps-1).
+-ifdef(HAVE_rand).
+seed() -> undefined.
+uniform(N) -> rand:uniform(N).
+-else.
+seed() -> random:seed(os:timestamp()).
+uniform(N) -> random:uniform(N).
+-endif.
+-compile({inline, [seed/0, uniform/1]}).
--
2.13.1