On Sunday, 27 September 2020 at 12:05:13 UTC, Ferhat Kurtulmuş wrote:
On Sunday, 27 September 2020 at 10:40:25 UTC, Ali Çehreli wrote:
On 9/27/20 3:06 AM, Ferhat Kurtulmuş wrote:

Oh, It will work fine if I imitate my time-consuming image processing like this.
I think it is Ok now.

import std.stdio;
import std.concurrency;
import core.thread;

void main() {
    foreach (v; 0..10){
        auto childTid = spawn(&spawnedFunc, thisTid);
        Thread.sleep(10.msecs); // imitate image processing
        send(childTid, v);

    }
    writeln("main is done.");
}

static void spawnedFunc(Tid ownerTid)
{
    receive((int v){
        Thread.sleep(1500.msecs);
        writeln(v);
    });
}

Reply via email to