Am 07.05.2014 19:06, schrieb Sönke Ludwig:
Am 07.05.2014 17:28, schrieb Bienlein:Hello Sönke, would it be possible in vibe.d to spawn a task the usual actor-style way as it is done with kernel threads in D? What I mean is this: void spawnedFunc(Tid tid) { receive( (int i) { writeln("Received the number ", i);} ); } auto tid = spawn(&spawnedFunc, thisTid); Thanks, BienleinThe Tid handling is currently a little different, but apart from that it should work like this: import vibe.core.core; import vibe.core.concurrency; void spawnedFunc(Tid tid) { receive( (int i) { writeln("Received the number ", i); } ); } // run it as a fiber in the same thread // note: runTask only takes a delegate to make runTask({ ... }) // work without an ambiguity error auto tid = runTask(toDelegate(&spawnedFunc), Task.getThis()); // or run it in the thread pool instead runWorkerTask(&spawnedFunc, Task.getThis()); Having said that, I'll just add a "thisTid" property to vibe.core.concurrency to make that part API compatible. I'd also add a "spawn" alias, but the question is if that should point to runTask or rather to runWorkerTask.
BTW, a runnable example can be found here: https://github.com/rejectedsoftware/vibe.d/blob/master/examples/message/source/app.d
