Browse Source

Create init_count worker in each pool at startup

Seth Falcon 14 years ago
parent
commit
821fbb90c6
2 changed files with 6 additions and 3 deletions
  1. 1 1
      src/pidq.app.src
  2. 5 2
      src/pidq.erl

+ 1 - 1
src/pidq.app.src

@@ -1,7 +1,7 @@
 {application, pidq,
  [
   {description, ""},
-  {vsn, "1"},
+  {vsn, git},
   {registered, []},
   {applications, [
                   kernel,

+ 5 - 2
src/pidq.erl

@@ -95,11 +95,14 @@ init(Config) ->
                   {ok, SupPid} = supervisor:start_child(pidq_pool_sup, [MFA]),
                   {Name, SupPid}
           end, PoolRecs),
-    % TODO: create initial workers here
-    State = #state{npools = length(Pools),
+    State0 = #state{npools = length(Pools),
                    pools = dict:from_list(Pools),
                    pool_sups = dict:from_list(PoolSups)
                   },
+    {ok, State} = lists:foldl(
+                    fun(#pool{name = PName, init_count = N}, {ok, AccState}) ->
+                            add_pids(PName, N, AccState)
+                    end, {ok, State0}, PoolRecs),
     process_flag(trap_exit, true),
     {ok, State}.