"Spawn as many thousand threads as you like" and D

Sönke Ludwig via Digitalmars-d digitalmars-d at puremagic.com
Wed Apr 16 07:21:03 PDT 2014


Am 16.04.2014 16:16, schrieb Bienlein:
> On Wednesday, 16 April 2014 at 14:06:13 UTC, Sönke Ludwig wrote:
>
>> I agree, but I also wonder why you still keep ignoring vibe.d. It
>> achieves exactly that - right now! Integration with std.concurrency
>> would be great, but at least for now it has an API compatible
>> replacement that can be merged later when Sean's pull request is done.
>
> The point is that vibe.d is a distributed solution. Nothing wrong about
> that. But in a single instance of some Go program you can >locally<
> spawn "as many threads as you like" with the number of threads easily
> being 50.000 and more. It seems that in the Go community people often do
> that without going distributed. Looks like this makes things a lot
> simpler when writing server-side applications.

I still don't understand what you mean by "distributed". Spawning 50.000 
tasks:

	import vibe.core.core;
	import std.stdio;
	
	void main()
	{
	    foreach (i; 0 .. 50_000)
		runTask({
			writefln("Hello, World!");
		});
	}

Alternatively, runWorkerTask will also distribute the tasks among a set 
of worker threads, which would be more in line with Go AFAIK.


More information about the Digitalmars-d mailing list