Am 16.04.2014 16:43, schrieb Bienlein:
On Wednesday, 16 April 2014 at 14:21:03 UTC, Sönke Ludwig wrote:

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.

All right, I see. I spent some time looking at the vibe.d homepage and I
never saw any other code than something like this:

shared static this()
{
     auto settings = new HTTPServerSettings;
     settings.port = 8080;

     listenHTTP(settings, &handleRequest);
}

void handleRequest(HTTPServerRequest req,
                    HTTPServerResponse res)
{
     res.writeBody("Hello, World!", "text/plain");
}


BTW, thank you for explaining the background, I think you were right that the focus is far too strong on the network part of the library, which can definitely be misleading (it was more appropriate two years ago, when most of this was written). I've taken the opportunity and updated a few pages to mention the non-I/O primitives and added a paragraph clarifying the use of yield:

All of this usually happens behind the curtain of the vibe.d API, so that 
everything feels like just working with normal threads and blocking operations. 
All blocking functions, such as sleep() or read() will yield execution whenever 
they need to wait for an event and let themselves resume when the event occurs.


Reply via email to