Просмотр исходного кода

Remove dependency on crypto application

Use a simpler and faster method of obtaining a random pool from a
group. Method taken from pg2. This removes the dependency on the
crypto application
Seth Falcon 12 лет назад
Родитель
Сommit
9a8ee44508
2 измененных файлов с 3 добавлено и 4 удалено
  1. 1 2
      src/pooler.app.src
  2. 2 2
      src/pooler.erl

+ 1 - 2
src/pooler.app.src

@@ -5,8 +5,7 @@
   {registered, []},
   {applications, [
                   kernel,
-                  stdlib,
-                  crypto
+                  stdlib
                  ]},
   {mod, { pooler_app, []}},
   {env, []}

+ 2 - 2
src/pooler.erl

@@ -63,7 +63,6 @@ start_link(#pool{name = Name} = Pool) ->
 
 manual_start() ->
     application:start(sasl),
-    application:start(crypto),
     application:start(pooler).
 
 %% @doc For INTERNAL use. Adds `MemberPid' to the pool.
@@ -91,7 +90,8 @@ take_group_member(GroupName) ->
         Members ->
             %% Put a random member at the front of the list and then
             %% return the first member you can walking the list.
-            Idx = crypto:rand_uniform(1, length(Members) + 1),
+            {_, _, X} = erlang:now(),
+            Idx = (X rem length(Members)) + 1,
             {Pid, Rest} = extract_nth(Idx, Members),
             take_first_member([Pid | Rest])
     end.