NSThread -setName:

  • I noticed that NSThread now allows setting the name of a thread for
    debugging purposes, a long overdue feature (Win32 has had this for quite
    some time).

    Is this functionality exposed at the Posix level? Our current threading
    code uses pthreads and I wouldn't want to rewrite it all just for names
    on threads unless I have to, but it's tempting nonetheless…
  • On Nov 8, 2007 4:41 PM, John Stiles <jstiles...> wrote:
    > I noticed that NSThread now allows setting the name of a thread for
    > debugging purposes, a long overdue feature (Win32 has had this for quite
    > some time).
    >
    > Is this functionality exposed at the Posix level? Our current threading
    > code uses pthreads and I wouldn't want to rewrite it all just for names
    > on threads unless I have to, but it's tempting nonetheless…

    No, it's an NSThread level concept.  There's a request out for a name
    at the posix level.

    -Ken
  • On Nov 8, 2007, at 4:41 PM, John Stiles wrote:

    > I noticed that NSThread now allows setting the name of a thread for
    > debugging purposes, a long overdue feature (Win32 has had this for
    > quite some time).
    >
    > Is this functionality exposed at the Posix level? Our current
    > threading code uses pthreads and I wouldn't want to rewrite it all
    > just for names on threads unless I have to, but it's tempting
    > nonetheless…

    It is not available at the pthread() APIs - we're doing this ourselves
    in NSThread.

    .chris

    --
    Chris Parker
    Cocoa Frameworks
    Apple Inc.
  • On Nov 8, 2007, at 5:15 PM, Ken Ferry wrote:

    > On Nov 8, 2007 4:41 PM, John Stiles <jstiles...> wrote:
    >> I noticed that NSThread now allows setting the name of a thread for
    >> debugging purposes, a long overdue feature (Win32 has had this for
    >> quite
    >> some time).
    >>
    >> Is this functionality exposed at the Posix level? Our current
    >> threading
    >> code uses pthreads and I wouldn't want to rewrite it all just for
    >> names
    >> on threads unless I have to, but it's tempting nonetheless…
    >
    > No, it's an NSThread level concept.  There's a request out for a name
    > at the posix level.

    When I saw "for debugging purposes," I mistakenly assumed that this
    means that the debugger would show the name.

    OK, I'm still waiting then… maybe in 10.6 :(
  • If the debugger doesn't display the thread name, then what is this
    useful for?

    On Nov 8, 2007, at 5:18 PM, Chris Parker wrote:

    >
    > On Nov 8, 2007, at 4:41 PM, John Stiles wrote:
    >
    >> I noticed that NSThread now allows setting the name of a thread for
    >> debugging purposes, a long overdue feature (Win32 has had this for
    >> quite some time).
    >>
    >> Is this functionality exposed at the Posix level? Our current
    >> threading code uses pthreads and I wouldn't want to rewrite it all
    >> just for names on threads unless I have to, but it's tempting
    >> nonetheless…
    >
    > It is not available at the pthread() APIs - we're doing this
    > ourselves in NSThread.
    >
    > .chris
    >
    > --
    > Chris Parker
    > Cocoa Frameworks
    > Apple Inc.
  • Looks to be just an "ivar" entry in NSThread. I
    think if you want it in posix, you need to use
    pthread_getspecific() or something. But it's
    nothing like Windows' support of named threads.
    (ie, you won't get love from gdb).

    Ack, at 11/8/07, John Stiles said:

    > I noticed that NSThread now allows setting the
    > name of a thread for debugging purposes, a long
    > overdue feature (Win32 has had this for quite
    > some time).
    >
    > Is this functionality exposed at the Posix
    > level? Our current threading code uses pthreads
    > and I wouldn't want to rewrite it all just for
    > names on threads unless I have to, but it's
    > tempting nonethelessŠ

    --

    Sincerely,
    Rosyna Keller
    Technical Support/Carbon troll/Always needs a hug

    Unsanity: Unsane Tools for Insanely Great People

    It's either this, or imagining Phil Schiller in a thong.
  • On Nov 8, 2007, at 5:21 PM, John Mikros wrote:

    > If the debugger doesn't display the thread name, then what is this
    > useful for?

    It's printed as part of the NSThread description (when you NSLog(),
    for instance), and you can ask the debugger to 'po' the current
    thread's description:

    (gdb) po [NSThread currentThread]
    <NSThread: 0x103db0>{name = Loader thread, num = 1}

    For a given thread, gdb doesn't know if there's an NSThread associated
    with the pthread or not, so it can't really do this automatically.

    Until the set-the-pthread-name API comes through, we're labeling what
    we can.

    .chris

    --
    Chris Parker
    Cocoa Frameworks Engineer
    Apple Inc.
previous month november 2007 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today