On Wednesday, 18 October 2017 at 11:04:10 UTC, Biotronic wrote:
On Wednesday, 18 October 2017 at 11:01:56 UTC, Per Nordlöw wrote:
On Wednesday, 18 October 2017 at 09:01:30 UTC, Per Nordlöw wrote:
Creates an actor (goroutine, whatever), which spawns 10 new actors, each of them spawns 10 more actors, etc. until one million actors are created on the final level. Then, each of them returns back its ordinal number (from 0 to 999999), which are summed on the previous level and sent back upstream, until reaching the root actor. (The answer should be 499999500000).

See also: https://github.com/atemerev/skynet

I Fibers aren't supposed to take any parameters how are we supposed to pass values to it during creation?

class MyFiber : Fiber {
    this(int arguments, string go, float here) {
        super(&run);
        // Save arguments somewhere
    }
    void run() {
        // Use arguments here.
    }
}

--
  Biotronic

Thanks, I figured that out myself after a while ;)

Another thing...how should the synchronization between the fibers figure out when the total number of fibers have reached one million?...via an atomic counter fed by reference to the constructor...or are there better ways? Because I do need an atomic reference counter here, right?

And how do I parallelize this over multiple worker threads? AFAICT fibers are by default all spawned in the same main thread, right?

Reply via email to