25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-26 17:38:45 +01:00
xmpp.chapril.org-ejabberd/src/randoms.erl
Alexey Shchepin 496c041b28 *** empty log message ***
SVN Revision: 16
2002-12-13 20:58:27 +00:00

43 lines
863 B
Erlang

%%%----------------------------------------------------------------------
%%% File : randoms.erl
%%% Author : Alexey Shchepin <alexey@sevcom.net>
%%% Purpose :
%%% Created : 13 Dec 2002 by Alexey Shchepin <alexey@sevcom.net>
%%% Id : $Id$
%%%----------------------------------------------------------------------
-module(randoms).
-author('alexey@sevcom.net').
-vsn('$Revision$ ').
-export([get_string/0]).
-export([start/0, init/0]).
start() ->
register(random_generator, spawn(randoms, init, [])).
init() ->
{A1, A2, A3} = now(),
random:seed(A1,A2,A3),
loop().
loop() ->
receive
{From, get_random, N} ->
From ! {random, random:uniform(N)},
loop();
_ ->
loop()
end.
get_string() ->
random_generator ! {self(), get_random, 65536*65536},
receive
{random, R} ->
integer_to_list(R)
end.