Giter VIP home page Giter VIP logo

Comments (3)

jeberger avatar jeberger commented on May 13, 2024

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.

jeberger avatar jeberger commented on May 13, 2024

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.

Araq avatar Araq commented on May 13, 2024

Thanks.

from nim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.