std.concurrency: ownerTid vs thisTid

miazo via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Feb 9 07:35:03 PST 2016


Hi,

The following simple program:

import std.stdio, std.concurrency;

void f1() {
     writeln("owner: ", ownerTid);
     writeln("worker: ", thisTid);
}

void main() {
     writeln("owner: ", thisTid);
     writeln("worker: ", spawn(&f1));
}

Gives me the following result:

owner: Tid(18fd58)
worker: Tid(18fd58)
owner: Tid(24afe38)
worker: Tid(24afe38)

Is it correct? My expectation was that:
- thisTid called from main will be the same as ownerTid called 
from f1
- thisTid called from f1 will be the same as value returned by 
spawn()

Thank you for your help.



More information about the Digitalmars-d-learn mailing list