getTid wrapper
ollie
ollie at home.net
Tue Mar 4 09:42:18 PST 2014
On Mon, 03 Mar 2014 20:39:17 -0800, 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 as explained here (http://ddili.org/ders/d.en/concurrency.html) so
> it's not useful for logging.
>
I ran into this problem with threads. You can't just take a pointer to a
thread (ie &Thread.getThis). You have to use a cast(void*) for it to work.
I put the following print statement where I created the thread and in the
created thread:
writefln("Thread %X is%s the main thread.", cast(void*)Thread.getThis,
thread_isMainThread ? "" : "n't");
This worked, otherwise using '&' to get the pointer gave the same address.
ollie
More information about the Digitalmars-d-learn
mailing list