1%% 2%% %CopyrightBegin% 3%% 4%% Copyright Ericsson AB 1998-2016. All Rights Reserved. 5%% 6%% Licensed under the Apache License, Version 2.0 (the "License"); 7%% you may not use this file except in compliance with the License. 8%% You may obtain a copy of the License at 9%% 10%% http://www.apache.org/licenses/LICENSE-2.0 11%% 12%% Unless required by applicable law or agreed to in writing, software 13%% distributed under the License is distributed on an "AS IS" BASIS, 14%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15%% See the License for the specific language governing permissions and 16%% limitations under the License. 17%% 18%% %CopyrightEnd% 19%% 20%% 21-module('rmod_random_impl'). 22-include("oe_random.hrl"). 23-export([init/1, terminate/2]). 24-export([produce/1,init/2]). 25 26 27init(Env) -> 28 {ok, []}. 29 30terminate(From, Reason) -> 31 ok. 32 33 34produce(_Random) -> 35 case catch random:uniform() of 36 {'EXIT',_} -> 37 true; 38 RUnif -> 39 {reply,RUnif,[]} 40 end. 41 42 43init(_Random,IData) -> 44 S1 = IData#seed.seed1, 45 S2 = IData#seed.seed2, 46 S3 = IData#seed.seed3, 47 case catch random:seed(S1,S2,S3) of 48 {'EXIT',_} -> 49 true; 50 _ -> 51 {noreply,[]} 52 end. 53 54