I have been using std.parallelism and that has worked quite nicely but it is not fully utilising all the cpu resources in my computation so I though it could be good to run it concurrently to see if I can get better performance. However I am very new to std.concurrency and the baby version of the code I am trying to run:

```
void main()
{
  import std.concurrency;
  import std.stdio: writeln;

  void process(double x, double y, long i, shared(double[]) z)
  {
    z[i] = x*y;
  }
  long n = 100;
  shared(double[]) z = new double[n];
  for(long i = 0; i < n; ++i)
  {
    spawn(&process, cast(double)(i), cast(double)(i + 1), i, z);
  }
  writeln("z: ", z);
}
```


Illicits the following error:

```
onlineapp.d(14): Error: template std.concurrency.spawn cannot deduce function from argument types !()(void delegate(double x, double y, long i, shared(double[]) z) pure nothrow @nogc @safe, double, double, long, shared(double[])), candidates are: /dlang/dmd/linux/bin64/../../src/phobos/std/concurrency.d(460): spawn(F, T...)(F fn, T args) with F = void delegate(double, double, long, shared(double[])) pure nothrow @nogc @safe,
       T = (double, double, long, shared(double[]))
  must satisfy the following constraint:
       isSpawnable!(F, T)
```


  • Error running concurrent proc... data pulverizer via Digitalmars-d-learn

Reply via email to