Fix director_thread test for MacOS
pthread_setname_np is defined differently on MacOS
This commit is contained in:
parent
d835c69d65
commit
50f223f454
1 changed files with 15 additions and 2 deletions
|
|
@ -94,13 +94,25 @@ extern "C" {
|
||||||
fprintf(stderr, "pthread_create failed in run()\n");
|
fprintf(stderr, "pthread_create failed in run()\n");
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
int setname = pthread_setname_np(thread, "MyThreadName");
|
%#endif
|
||||||
|
MilliSecondSleep(500);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setThreadName() {
|
||||||
|
%#ifdef _WIN32
|
||||||
|
%#else
|
||||||
|
|
||||||
|
%#ifdef __APPLE__
|
||||||
|
int setname = pthread_setname_np("MyThreadName");
|
||||||
|
%#else
|
||||||
|
int setname = pthread_setname_np(pthread_self(), "MyThreadName");
|
||||||
|
%#endif
|
||||||
|
|
||||||
if (setname != 0) {
|
if (setname != 0) {
|
||||||
fprintf(stderr, "pthread_setname_np failed in run()\n");
|
fprintf(stderr, "pthread_setname_np failed in run()\n");
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
%#endif
|
%#endif
|
||||||
MilliSecondSleep(500);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool namedThread() {
|
static bool namedThread() {
|
||||||
|
|
@ -126,6 +138,7 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
Foo* f = static_cast<Foo*>(t);
|
Foo* f = static_cast<Foo*>(t);
|
||||||
|
f->setThreadName();
|
||||||
while (!get_thread_terminate()) {
|
while (!get_thread_terminate()) {
|
||||||
MilliSecondSleep(50);
|
MilliSecondSleep(50);
|
||||||
f->do_foo();
|
f->do_foo();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue