aboutsummaryrefslogtreecommitdiff
path: root/modules/desktop_capture/screen_drawer_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'modules/desktop_capture/screen_drawer_unittest.cc')
-rw-r--r--modules/desktop_capture/screen_drawer_unittest.cc14
1 files changed, 6 insertions, 8 deletions
diff --git a/modules/desktop_capture/screen_drawer_unittest.cc b/modules/desktop_capture/screen_drawer_unittest.cc
index c38eee6991..2394260105 100644
--- a/modules/desktop_capture/screen_drawer_unittest.cc
+++ b/modules/desktop_capture/screen_drawer_unittest.cc
@@ -48,13 +48,12 @@ void TestScreenDrawerLock(
~Task() = default;
- static void RunTask(void* me) {
- Task* task = static_cast<Task*>(me);
- std::unique_ptr<ScreenDrawerLock> lock = task->ctor_();
+ void RunTask() {
+ std::unique_ptr<ScreenDrawerLock> lock = ctor_();
ASSERT_TRUE(!!lock);
- task->created_->store(true);
+ created_->store(true);
// Wait for the main thread to get the signal of created_.
- while (!task->ready_.load()) {
+ while (!ready_.load()) {
SleepMs(1);
}
// At this point, main thread should begin to create a second lock. Though
@@ -77,8 +76,8 @@ void TestScreenDrawerLock(
const rtc::FunctionView<std::unique_ptr<ScreenDrawerLock>()> ctor_;
} task(&created, ready, ctor);
- rtc::PlatformThread lock_thread(&Task::RunTask, &task, "lock_thread");
- lock_thread.Start();
+ auto lock_thread = rtc::PlatformThread::SpawnJoinable(
+ [&task] { task.RunTask(); }, "lock_thread");
// Wait for the first lock in Task::RunTask() to be created.
// TODO(zijiehe): Find a better solution to wait for the creation of the first
@@ -95,7 +94,6 @@ void TestScreenDrawerLock(
ASSERT_GT(kLockDurationMs, rtc::TimeMillis() - start_ms);
ctor();
ASSERT_LE(kLockDurationMs, rtc::TimeMillis() - start_ms);
- lock_thread.Stop();
}
} // namespace