| 385 | } |
| 386 | |
| 387 | void Thread::SetName(const char* name) |
| 388 | { |
| 389 | if (_sharedBlock == nullptr || _sharedBlock->_handle == 0) { |
| 390 | return; |
| 391 | } |
| 392 | |
| 393 | #if defined(DEATH_TARGET_WINDOWS) |
| 394 | SetThreadName(_sharedBlock->_handle, name); |
| 395 | #elif !defined(DEATH_TARGET_APPLE) && !defined(DEATH_TARGET_EMSCRIPTEN) && !defined(DEATH_TARGET_SWITCH) |
| 396 | const auto nameLength = strnlen(name, MaxThreadNameLength); |
| 397 | if (nameLength <= MaxThreadNameLength - 1) { |
| 398 | pthread_setname_np(_sharedBlock->_handle, name); |
| 399 | } else { |
| 400 | char buffer[MaxThreadNameLength]; |
| 401 | memcpy(buffer, name, MaxThreadNameLength - 1); |
| 402 | buffer[MaxThreadNameLength - 1] = '\0'; |
| 403 | pthread_setname_np(_sharedBlock->_handle, name); |
| 404 | } |
| 405 | #endif |
| 406 | } |
| 407 | |
| 408 | void Thread::SetCurrentName(const char* name) |
| 409 | { |
nothing calls this directly
no test coverage detected