Comments (3)
The following patch fixes the issue:
--- a/lib/pure/actors.nim Wed Nov 30 19:52:09 2011 +0100 +++ b/lib/pure/actors.nim Sat Dec 03 17:24:02 2011 +0100 @@ -129,24 +129,24 @@ 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.}
from nim.
I chose my examples poorly :( The patch works whatever the name of the pool (the fact that you need to use "p" in the "schedule" template is due to the parameter name in spawn, not the name in my example)
from nim.
Thanks.
from nim.
Related Issues (20)
- sequtils templates (mapIt, etc) don't work with set card HOT 2
- `<expr> is` crashes nimsuggest
- Regression from 1.6/2.0.4/devel to 2.0.5: `Error: toException(self.eResultPrivate) can raise an unlisted exception: ref LPError` HOT 15
- anonymous closure iterators doesn't work with global variable in JS
- Top level variables are moved sometimes
- `nim c -c` on `{.push emit.}`: `Error: unhandled exception: field 'sons' is not accessible for type 'TNode' using 'kind = nkIdent' [FieldDefect]`
- Spurious effects regression from Nim 2.0.4 to 2.0.5 HOT 1
- `Error: fatal error: invalid kind for lastOrd(tyGenericParam)` in compiler given invalid array declaration HOT 2
- compilation error/regression from 2.0.4 to 2.0.5: `Error: unhandled exception: field 'sym' is not accessible for type 'TNode' using 'kind = nkIntLit' [FieldDefect]` HOT 1
- `if nil == X` crashes the compiler HOT 1
- Stack trace with wrong line number when the proc called inside for loop
- Moves disallowed in top-level block
- IEEE NaN makes std/algorithm.nextPermutation infinite loop HOT 1
- C compiler error when default initializing an object field function when the default function is overloaded HOT 5
- Semi-regression (?): generic typeclass not matching HOT 3
- Docs rendering on smaller devices HOT 2
- Invalid codegen when trying to mannualy delete distinct seq HOT 3
- In NimScript mode, make `commandLineParams()` more useful
- Allow `array[..., void]` HOT 3
- `typeinfo.extendSeq` generates random values
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nim.