Update PlatformThread constructor to take name with absl::string_view
PlatfromThread is used by several TaskQueue implementations that plan to take it's name as string_view and thus wouldn't guarantee it is 0-terminated. Bug: webrtc:10191 Change-Id: I7dadb917192257f0185f9cb4f0ec207d7156d3c3 Reviewed-on: https://webrtc-review.googlesource.com/c/118140 Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/master@{#26317}
This commit is contained in:
parent
2ec0c650e9
commit
5a1a6dba5c
@ -272,6 +272,7 @@ rtc_source_set("platform_thread") {
|
|||||||
":rtc_event",
|
":rtc_event",
|
||||||
":thread_checker",
|
":thread_checker",
|
||||||
":timeutils",
|
":timeutils",
|
||||||
|
"//third_party/abseil-cpp/absl/strings",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -39,10 +39,8 @@ struct ThreadAttributes {
|
|||||||
|
|
||||||
PlatformThread::PlatformThread(ThreadRunFunctionDeprecated func,
|
PlatformThread::PlatformThread(ThreadRunFunctionDeprecated func,
|
||||||
void* obj,
|
void* obj,
|
||||||
const char* thread_name)
|
absl::string_view thread_name)
|
||||||
: run_function_deprecated_(func),
|
: run_function_deprecated_(func), obj_(obj), name_(thread_name) {
|
||||||
obj_(obj),
|
|
||||||
name_(thread_name ? thread_name : "webrtc") {
|
|
||||||
RTC_DCHECK(func);
|
RTC_DCHECK(func);
|
||||||
RTC_DCHECK(name_.length() < 64);
|
RTC_DCHECK(name_.length() < 64);
|
||||||
spawned_thread_checker_.DetachFromThread();
|
spawned_thread_checker_.DetachFromThread();
|
||||||
@ -50,7 +48,7 @@ PlatformThread::PlatformThread(ThreadRunFunctionDeprecated func,
|
|||||||
|
|
||||||
PlatformThread::PlatformThread(ThreadRunFunction func,
|
PlatformThread::PlatformThread(ThreadRunFunction func,
|
||||||
void* obj,
|
void* obj,
|
||||||
const char* thread_name,
|
absl::string_view thread_name,
|
||||||
ThreadPriority priority /*= kNormalPriority*/)
|
ThreadPriority priority /*= kNormalPriority*/)
|
||||||
: run_function_(func), priority_(priority), obj_(obj), name_(thread_name) {
|
: run_function_(func), priority_(priority), obj_(obj), name_(thread_name) {
|
||||||
RTC_DCHECK(func);
|
RTC_DCHECK(func);
|
||||||
|
|||||||
@ -16,6 +16,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "absl/strings/string_view.h"
|
||||||
#include "rtc_base/constructor_magic.h"
|
#include "rtc_base/constructor_magic.h"
|
||||||
#include "rtc_base/platform_thread_types.h"
|
#include "rtc_base/platform_thread_types.h"
|
||||||
#include "rtc_base/thread_checker.h"
|
#include "rtc_base/thread_checker.h"
|
||||||
@ -51,10 +52,10 @@ class PlatformThread {
|
|||||||
public:
|
public:
|
||||||
PlatformThread(ThreadRunFunctionDeprecated func,
|
PlatformThread(ThreadRunFunctionDeprecated func,
|
||||||
void* obj,
|
void* obj,
|
||||||
const char* thread_name);
|
absl::string_view thread_name);
|
||||||
PlatformThread(ThreadRunFunction func,
|
PlatformThread(ThreadRunFunction func,
|
||||||
void* obj,
|
void* obj,
|
||||||
const char* thread_name,
|
absl::string_view thread_name,
|
||||||
ThreadPriority priority = kNormalPriority);
|
ThreadPriority priority = kNormalPriority);
|
||||||
virtual ~PlatformThread();
|
virtual ~PlatformThread();
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user