SkyWay Linux SDK
読み取り中…
検索中…
一致する文字列を見つけられません
thread_utils.hpp
1//
2// © NTT DOCOMO BUSINESS, Inc. All Rights Reserved.
3//
4
5#ifndef SKYWAY_ANDROID_SDK_THREAD_UTILS_HPP
6#define SKYWAY_ANDROID_SDK_THREAD_UTILS_HPP
7
8#ifdef WEBRTC_ANDROID
9#include <sys/prctl.h>
10#endif
11
12#if defined(WEBRTC_IOS) || defined(WEBRTC_LINUX)
13#include <pthread.h>
14#endif
15#include <string>
16
17namespace skyway{
18namespace global {
19namespace util {
20
21inline int SetThreadName(const std::string& name) {
22 // TODO: Support Unity
23#if defined(WEBRTC_ANDROID)
24#if __ANDROID_API__ < 24
25 // pthread_setname_np() requires Android API 24 or later.
26 return prctl(PR_SET_NAME, name.c_str());
27#else
28 return pthread_setname_np(pthread_self(), name.c_str());
29#endif
30
31#elif defined(WEBRTC_IOS)
32 return pthread_setname_np(name.c_str());
33#elif defined(WEBRTC_LINUX)
34 return pthread_setname_np(pthread_self(), name.c_str());
35#endif
36 return 0;
37}
38
39}
40}
41}
42
43#endif //SKYWAY_ANDROID_SDK_THREAD_UTILS_HPP