<div dir="ltr">Thanks, that works <div>does it make sense to add a function to do that?<div>as it stands there are 2 separate ways, <span style="font-family:arial,sans-serif;font-size:13px"> cast(void*)Thread.getThis and cast(void*)getTid, so having a function would make it the preferred way.</span><div>
<span style="font-family:arial,sans-serif;font-size:13px"><br></span></div></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Mar 4, 2014 at 9:42 AM, ollie <span dir="ltr"><<a href="mailto:ollie@home.net" target="_blank">ollie@home.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On Mon, 03 Mar 2014 20:39:17 -0800, Timothee Cour wrote:<br>
<br>
> 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<br>
</div><div class="">> threads as explained here (<a href="http://ddili.org/ders/d.en/concurrency.html" target="_blank">http://ddili.org/ders/d.en/concurrency.html</a>) so<br>
> it's not useful for logging.<br>
><br>
<br>
</div>I ran into this problem with threads. You can't just take a pointer to a<br>
thread (ie &Thread.getThis). You have to use a cast(void*) for it to work.<br>
I put the following print statement where I created the thread and in the<br>
created thread:<br>
<br>
    writefln("Thread %X is%s the main thread.", cast(void*)Thread.getThis,<br>
              thread_isMainThread ? "" : "n't");<br>
<br>
This worked, otherwise using '&' to get the pointer gave the same address.<br>
<span class="HOEnZb"><font color="#888888"><br>
ollie<br>
</font></span></blockquote></div><br></div>