https://issues.dlang.org/show_bug.cgi?id=15076
Issue ID: 15076
Summary: Get ID of current thread
Product: D
Version: D2
Hardware: All
OS: Windows
Status: NEW
Severity: enhancement
Priority: P1
Component: druntime
Assignee: [email protected]
Reporter: [email protected]
core.thread is missing a function to get the ID of the current thread. getpid
is insufficient, as even on POSIX it will return the same value for all
threads:
///////// test.d /////////
import core.thread;
import std.stdio;
void main()
{
writeln(getpid());
new Thread({
writeln(getpid());
}).start();
}
//////////////////////////
Essentially, it should be GetCurrentThreadId() on Windows and pthread_self() on
POSIX (same logic as for initializing Thread.m_addr).
--