[Issue 15076] Get ID of current thread

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Sep 17 08:51:45 PDT 2015


https://issues.dlang.org/show_bug.cgi?id=15076

Vladimir Panteleev <thecybershadow at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #4 from Vladimir Panteleev <thecybershadow at gmail.com> ---
https://github.com/D-Programming-Language/druntime/pull/1388
https://github.com/D-Programming-Language/phobos/pull/3654

(In reply to Jonathan M Davis from comment #2)
> I would think that the most natural thing to do (and what most folks would
> likely look for) would be a static function/property on core.thread.Thread -
> e.g. Thread.currThreadID - since that's where the thread stuff is.

Then we would have three conventions for such functions.

Currently, there is core.thread.getpid and std.process.thisProcessID.
Introducing something that's unlike neither of these would be very
inconsistent.

(In reply to Steven Schveighoffer from comment #3)
> What is the use case for this? Why doesn't Thread.getThis suffice?

Thread.getThis:

1. Returns a pointer, not the OS identifier. The pointer cannot be unique
per-process (esp. in the case of multiple D runtimes).

2. Requires that the current thread is registered with the D runtime. If it
isn't, it returns null.

--


More information about the Digitalmars-d-bugs mailing list