std.concurrency: ownerTid vs thisTid

Daniel Kozak via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Feb 9 07:52:44 PST 2016


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/1518af34/attachment.html>


More information about the Digitalmars-d-learn mailing list