uwiger / gproc

Extended process registry for Erlang
Apache License 2.0
1.07k stars 232 forks source link

unexpected behaviour for gproc_pool:defined_workers/1 #57

Closed bosky101 closed 10 years ago

bosky101 commented 10 years ago
 > application:start(gproc).

 > gproc_pool:setup_test_pool(p2,round_robin,[]).
 add_worker(p2, a) -> 1; Ws = [{a,1}]
 add_worker(p2, b) -> 2; Ws = [{a,1},{b,2}]
 add_worker(p2, c) -> 3; Ws = [{a,1},{b,2},{c,3}]
 add_worker(p2, d) -> 4; Ws = [{a,1},{b,2},{c,3},{d,4}]
 add_worker(p2, e) -> 5; Ws = [{a,1},{b,2},{c,3},{d,4},{e,5}]
 add_worker(p2, f) -> 6; Ws = [{a,1},{b,2},{c,3},{d,4},{e,5},{f,6}]
 [true,true,true,true,true,true]

worker_pool/1 shows the said workers

 >gproc_pool:worker_pool(p2).
 [{a,1},{b,2},{c,3},{d,4},{e,5},{f,6}]

but defined_workers does not.

 > gproc_pool:defined_workers(p2).
 ** exception error: bad argument
      in function  ets:lookup_element/3
         called as ets:lookup_element(gproc,
                                      {{c,l,{gproc_pool,p2,w,a}},<0.71.0>},
                                      3)
      in call from gproc:get_value1/2 (src/gproc.erl, line 1392)
      in call from gproc:get_value/1 (src/gproc.erl, line 1365)
      in call from gproc_pool:'-defined_workers/1-lc$^0/1-0-'/2 (src/gproc_pool.erl, line 

I also noticed though that after the workers pass a few messages around, it does not crash. is some application or operation a pre-requisite before running defined_workers?

The docs say that defined_workers also gives stats about how often a worker is picked. Running pick > length of workers and then querying defined_workers/1 still gave me the error.

uwiger commented 10 years ago

I pushed a fix to master.

bosky101 commented 10 years ago

great. verified.

> gproc_pool:defined_workers(p2).
[{a,1,0},{b,2,0},{c,3,0},{d,4,0},{e,5,0},{f,6,0}]