On Tuesday, 15 August 2017 at 10:37:08 UTC, Kagamin wrote:
Well, no wrapper is actually needed here:

class A
{
        int method() shared;
}

void consumer()
{
        shared a = receiveOnly!(shared A)();
}

void producer()
{
        auto cons = spawn(&consumer);
        send(cons, new shared A());
}

Yes, but this doesn't compile:

import std.stdio;
import std.concurrency;

struct A
{
        int t;
        int r;
        int method() shared
        {
                return 0;
        }
}

void consumer()
{
        shared a = receiveOnly!(shared A)();
}

void main()
{
        auto cons = spawn(&consumer);
        send(cons, shared A());
}

This very simple code also doesn't compile:

shared struct S
{
        int i;

        ~this()
        {
        }
}

void main()
{
        shared s = shared S();
}

In general, shared structs with postblit and destructor make problems.

Arek

Reply via email to