25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-24 17:29:28 +01:00
xmpp.chapril.org-ejabberd/src/randoms.erl

42 lines
842 B
Erlang
Raw Normal View History

%%%----------------------------------------------------------------------
%%% 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').
-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.