Mac/iPhone: Is there a way to get a thread identifier without using Objective-C?

前端 未结 4 1323
南旧
南旧 2021-02-02 16:40

Is there a way to get any kind of thread identifier of the currently running thread without resorting to Objective-C\'s NSThread.

I\'m improving our custom debug tracing

4条回答
  •  故里飘歌
    2021-02-02 16:59

    See pthread_getname_np.

    Unfortunately NSThread's name is not currently pushed down to that. The NSThread name is just an ivar, so there will be no way to get at it except through the method. You could always make a C function that makes the autorelease pool and gets the name. Your C++ code then doesn't have to be compiled as ObjC++.

    pthread_getname_np is probably a bit more useful than NSThread's name right now anyway. gdb and Instruments don't know about NSThread's name, only the pthread level name.

提交回复
热议问题