std.concurrency: ownerTid vs thisTid

Daniel Kozak via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Feb 9 08:25:32 PST 2016


You are right:
import std.stdio, std.concurrency;
import std.concurrency : MessageBox;

struct MyTid
{
    MessageBox mbox;
}

static void f1() {
    auto tT = cast(MyTid)thisTid;
    auto oT = cast(MyTid)ownerTid;
    writeln("F1:worker: ", cast(void*)tT.mbox);
    writeln("F1:owner: ", cast(void*)oT.mbox);
}

void main() {
    auto tT = cast(MyTid)thisTid();
    auto sT = cast(MyTid)spawn(&f1);
    writeln("Main:worker: ", cast(void *)sT.mbox);
    writeln("Main:owner: ", cast(void *)tT.mbox);
}


On Tue, Feb 9, 2016 at 4:55 PM, Ali Çehreli <
digitalmars-d-learn at puremagic.com> wrote:

> On 02/09/2016 07:52 AM, Daniel Kozak via Digitalmars-d-learn wrote:
>
>> It is OK, I guess the output is just mixed
>>
>
> Yes, that's an important point but it is not the reason. (Just tested.)
>
> I think this is just an issue with how Tid objects are printed. Otherwise,
> everything works as expected and although they print the same value,
> "worker1 != worker2" is true as well.
>
> Ali
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20160209/bdd75985/attachment.html>


More information about the Digitalmars-d-learn mailing list