Thread overview
[Issue 6989] New: Implement toString for std.concurrency.Tid
Nov 22, 2011
Andrej Mitrovic
Jan 25, 2013
Andrej Mitrovic
Mar 25, 2013
Andrej Mitrovic
Sep 17, 2013
Andrej Mitrovic
November 22, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6989

           Summary: Implement toString for std.concurrency.Tid
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: andrej.mitrovich@gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2011-11-22 13:11:43 PST ---
Currently calling write() on a Tid prints:
Tid(std.concurrency.MessageBox)

In earlier versions this used to be:
Tid

In either case, this isn't much information. I think it would be useful if toString was overloaded and returned a string with some sort of unique thread ID, e.g.:

writeln(spawn(&test));  // Tid(0x0001)

This could make it easier to debug some types of threading problems without having to use a debugger.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 25, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6989



--- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-01-25 11:42:52 PST ---
Hmm it looks like there isn't such a thing as a cross-platform thread-identifier (at least not in Druntime).

Personally I like the idea of having named threads, where the name would be stored in a Tid. So you could do things like:

spawn("workThread", &func, args);

where the first pointer argument is the function. It might help with debugging, e.g. inspecting a Tid of a LinkTerminated exception could tell you which named thread threw the exception.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 25, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6989



--- Comment #2 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-03-25 11:34:26 PDT ---
(In reply to comment #1)
> Hmm it looks like there isn't such a thing as a cross-platform thread-identifier (at least not in Druntime).

Nevermind, there's actually m_addr, which is a uint on Windows and pthread_t on Posix (a pointer to _opaque_pthread_t).

So I think core.thread.Thread should expose a getThreadID() function which
returns m_addr, and then Tid can expose this function internally and also use
it for toString().

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 17, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6989


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
           Platform|Other                       |All
         AssignedTo|nobody@puremagic.com        |andrej.mitrovich@gmail.com
         OS/Version|Windows                     |All


--- Comment #3 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-09-17 13:30:06 PDT ---
https://github.com/D-Programming-Language/phobos/pull/1582

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------