std.concurrency: ownerTid vs thisTid

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


https://github.com/D-Programming-Language/phobos/blob/v2.070.0/std/concurrency.d#L340

formattedWrite(sink, "Tid(%x)", &mbox);

should be:

formattedWrite(sink, "Tid(%x)", cast(void *)mbox);

On Tue, Feb 9, 2016 at 5:25 PM, Daniel Kozak <kozzi11 at gmail.com> wrote:
> 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
>>
>



More information about the Digitalmars-d-learn mailing list