-
Notifications
You must be signed in to change notification settings - Fork 214
Open
Description
大神你好.拜读代码和博客,写的都非常详细,对我帮助很大.十分感谢~
现在有个小问题:代码173行和179行有两次主线程判断,能否解释一下为什么这样做?是有什么特殊的处理吗?
个人理解第一个主线程判断 return 掉以后,第二个判断应该是走不到的.
望解答~
if ([nsthread isMainThread]) {
return (thread_t)main_thread_id;
}
for (int i = 0; i < count; ++i) {
pthread_t pt = pthread_from_mach_thread_np(list[i]);
if ([nsthread isMainThread]) {
if (list[i] == main_thread_id) {
return list[i];
}
}
if (pt) {
name[0] = '\0';
pthread_getname_np(pt, name, sizeof name);
if (!strcmp(name, [nsthread name].UTF8String)) {
[nsthread setName:originName];
return list[i];
}
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels