std.concurrency: ownerTid vs thisTid
Daniel Kozak via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Feb 9 08:01:58 PST 2016
OK it seems wierd
On Tue, Feb 9, 2016 at 4:52 PM, Daniel Kozak <kozzi11 at gmail.com> wrote:
> It is OK, I guess the output is just mixed
>
> On Tue, Feb 9, 2016 at 4:35 PM, miazo via Digitalmars-d-learn <
> digitalmars-d-learn at puremagic.com> wrote:
>
>> 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.
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20160209/f75eb423/attachment.html>
More information about the Digitalmars-d-learn
mailing list