I suggest looking at std.parallelism since it's designed for this kind of thing. That aside, all traditional synchronization methods are in core.sync. The equivalent of "sync" in Cylk would be core.sync.barrier.

Thanks. I wrote this:

#!/usr/bin/env rdmd

import std.stdio;
import std.concurrency;
import std.algorithm;
import core.sync.barrier;
import core.thread;

void sorter(Tid owner, shared(int)[] sliceToSort, int mynumber)
{
    writefln("Came inside  %s", mynumber);
    sort(sliceToSort);
    writefln("Going out of %s", mynumber);

}

void main()
{
    shared numbers = [ 6, 5, 4, 3, 2, 1 ];
    auto barrier = new Barrier(2);
    spawn(&sorter, thisTid, numbers[0 .. $ / 2],  0);
    spawn(&sorter, thisTid, numbers[$ / 2 .. $],1 );

    writefln("Waiting for barrier in main");
    barrier.wait();

    writeln(numbers);
}

It compiles but barrier does not get released. Can you please point out the fault. Pardon my mistake. I searched whole web, there are almost no examples of it online.


I saw this: http://www.digitalmars.com/d/archives/digitalmars/D/bugs/Issue_9005_New_std.concurrency.spawn_should_allow_void_delegate_Args_shared_for_new_Tid_44426.html

but it does not compile.

Reply via email to