getTid wrapper
Timothee Cour
thelastmammoth at gmail.com
Tue Mar 4 07:52:16 PST 2014
On Tue, Mar 4, 2014 at 2:34 AM, Stanislav Blinov <stanislav.blinov at gmail.com
> wrote:
> On Tuesday, 4 March 2014 at 04:39:33 UTC, Timothee Cour wrote:
>
>> I couldn't find a wrapper to get current thread id.
>> There is Thread.getThis but the address it returns is the same for all
>> threads
>>
>
> That is not true.
>
>
> as explained here (http://ddili.org/ders/d.en/concurrency.html)
>>
>
> Where exactly?
quoting from there:
"The type of thisTid is Tid, but its value has no significance for the
program. Further, both threads report it to be surprisingly at the same
address:
Owner : Tid(std.concurrency.MessageBox), address: 809C360
Worker: Tid(std.concurrency.MessageBox), address: 809C360"
Likewise with writeln(&Thread.getThis);
> I couldn't find it, but if Ali's book states that Thread.getThis() returns
> the same reference, it's a bug in the book that should be fixed.
>
>
> auto getTid() to class Thread
>>
>
> core.thread.Thread.getThis();
> std.concurrency.thisTid;
>
> The latter one is mentioned in that same chapter.
>
How would I print a number/string that uniquely identifies a thread?
Tid is an opaque type, writeln(thisTid) isn't of any use.
struct Tid
{
private:
this( MessageBox m )
{
mbox = m;
}
MessageBox mbox;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20140304/0f2b3925/attachment.html>
More information about the Digitalmars-d-learn
mailing list