From e71b9147756ab4da306e4c16461ad23936769603 Mon Sep 17 00:00:00 2001 From: Brian Carlstrom Date: Sat, 12 Mar 2016 16:08:12 -0800 Subject: [PATCH] system/core: Make Thread::run threadName argument required Bug: 27557176 Change-Id: Iae83a1e5489c86c2858fc8481f246b8480f0eec4 --- include/utils/Thread.h | 2 +- libutils/Threads.cpp | 2 ++ libutils/tests/Looper_test.cpp | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/utils/Thread.h b/include/utils/Thread.h index 1532b7e0c..3792db7ba 100644 --- a/include/utils/Thread.h +++ b/include/utils/Thread.h @@ -45,7 +45,7 @@ public: virtual ~Thread(); // Start the thread in threadLoop() which needs to be implemented. - virtual status_t run( const char* name = 0, + virtual status_t run( const char* name, int32_t priority = PRIORITY_DEFAULT, size_t stack = 0); diff --git a/libutils/Threads.cpp b/libutils/Threads.cpp index 6dda6b573..def739f9f 100644 --- a/libutils/Threads.cpp +++ b/libutils/Threads.cpp @@ -668,6 +668,8 @@ status_t Thread::readyToRun() status_t Thread::run(const char* name, int32_t priority, size_t stack) { + LOG_ALWAYS_FATAL_IF(name == nullptr, "thread name not provided to Thread::run"); + Mutex::Autolock _l(mLock); if (mRunning) { diff --git a/libutils/tests/Looper_test.cpp b/libutils/tests/Looper_test.cpp index 00077e676..17319e03f 100644 --- a/libutils/tests/Looper_test.cpp +++ b/libutils/tests/Looper_test.cpp @@ -138,7 +138,7 @@ TEST_F(LooperTest, PollOnce_WhenNonZeroTimeoutAndAwokenBeforeWaiting_Immediately TEST_F(LooperTest, PollOnce_WhenNonZeroTimeoutAndAwokenWhileWaiting_PromptlyReturns) { sp delayedWake = new DelayedWake(100, mLooper); - delayedWake->run(); + delayedWake->run("LooperTest"); StopWatch stopWatch("pollOnce"); int result = mLooper->pollOnce(1000); @@ -251,7 +251,7 @@ TEST_F(LooperTest, PollOnce_WhenNonZeroTimeoutAndSignalledFDWhileWaiting_Promptl sp delayedWriteSignal = new DelayedWriteSignal(100, & pipe); handler.setCallback(mLooper, pipe.receiveFd, Looper::EVENT_INPUT); - delayedWriteSignal->run(); + delayedWriteSignal->run("LooperTest"); StopWatch stopWatch("pollOnce"); int result = mLooper->pollOnce(1000);