<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Mar 4, 2014 at 2:34 AM, Stanislav Blinov <span dir="ltr"><<a href="mailto:stanislav.blinov@gmail.com" target="_blank">stanislav.blinov@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="">On Tuesday, 4 March 2014 at 04:39:33 UTC, Timothee Cour wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
I couldn't find a wrapper to get current thread id.<br>
There is Thread.getThis but the address it returns is the same for all threads<br>
</blockquote>
<br></div>
That is not true.<div class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
as explained here (<a href="http://ddili.org/ders/d.en/concurrency.html" target="_blank">http://ddili.org/ders/d.en/<u></u>concurrency.html</a>)<br>
</blockquote>
<br></div>
Where exactly? </blockquote><div><br></div><div>quoting from there:</div><div>"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:</div>
<div>Owner : Tid(std.concurrency.MessageBox), address: 809C360</div><div>Worker: Tid(std.concurrency.MessageBox), address: 809C360"</div><div><br></div><div><br></div><div>Likewise with writeln(&Thread.getThis);</div>
<div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">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.<div class="">
<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
auto getTid() to class Thread<br>
</blockquote>
<br></div>
core.thread.Thread.getThis();<br>
std.concurrency.thisTid;<br>
<br>
The latter one is mentioned in that same chapter.<br></blockquote><div><br></div><div>How would I print a number/string that uniquely identifies a thread?</div><div><br></div><div>Tid is an opaque type, writeln(thisTid) isn't of any use.</div>
<div><br></div><div>struct Tid</div><div>{</div><div>private:</div><div>    this( MessageBox m )</div><div>    {</div><div>        mbox = m;</div><div>    }</div><div><br></div><div><br></div><div>    MessageBox  mbox;</div>
<div>}</div><div> </div></div><br></div></div>