diff options
author | Araq <rumpf_a@web.de> | 2011-12-04 20:21:38 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2011-12-04 20:21:38 +0100 |
commit | 24e1d22ec9b6361a2e2ae607a1ed69cca51ac1b2 (patch) | |
tree | 00d56d647ab9ba1f68335d5be5194afbcc3347d3 | |
parent | 3c4260f5041ac91316f0c6b1fe3d42c85e2a9389 (diff) | |
download | Nim-24e1d22ec9b6361a2e2ae607a1ed69cca51ac1b2.tar.gz |
fixes 70
-rw-r--r-- | lib/pure/actors.nim | 14 | ||||
-rw-r--r-- | tests/threads/tactors.nim | 8 |
2 files changed, 11 insertions, 11 deletions
diff --git a/lib/pure/actors.nim b/lib/pure/actors.nim index 4576cb602..2510bb8cd 100644 --- a/lib/pure/actors.nim +++ b/lib/pure/actors.nim @@ -129,24 +129,24 @@ template setupTask = template schedule = # extremely simple scheduler: We always try the first thread first, so that # it remains 'hot' ;-). Round-robin hurts for keeping threads hot. - for i in 0..high(a.actors): - if a.actors[i].i.ready: - a.actors[i].i.send(t) + for i in 0..high(p.actors): + if p.actors[i].i.ready: + p.actors[i].i.send(t) return # no thread ready :-( --> send message to the thread which has the least # messages pending: var minIdx = 0 var minVal = high(int) - for i in 0..high(a.actors): - var curr = a.actors[i].i.peek + for i in 0..high(p.actors): + var curr = p.actors[i].i.peek if curr == 0: # ok, is ready now: - a.actors[i].i.send(t) + p.actors[i].i.send(t) return if curr < minVal: minVal = curr minIdx = i - a.actors[minIdx].i.send(t) + p.actors[minIdx].i.send(t) proc spawn*[TIn, TOut](p: var TActorPool[TIn, TOut], input: TIn, action: proc (input: TIn): TOut {.thread.} diff --git a/tests/threads/tactors.nim b/tests/threads/tactors.nim index d6297d6bc..45a03ebb7 100644 --- a/tests/threads/tactors.nim +++ b/tests/threads/tactors.nim @@ -5,9 +5,9 @@ discard """ import actors var - a: TActorPool[int, void] -createActorPool(a) + pool: TActorPool[int, void] +createActorPool(pool) for i in 0 .. < 300: - a.spawn(i, proc (x: int) {.thread.} = echo x) -a.join() + pool.spawn(i, proc (x: int) {.thread.} = echo x) +pool.join() |