| Index: runtime/vm/thread_test.cc
|
| diff --git a/runtime/vm/thread_test.cc b/runtime/vm/thread_test.cc
|
| index 6f6075dea1ce85e2a510b45fbf6be482c30d9bbc..9eaf79138cff317d4d6f5bcf017bab89e1c8da1e 100644
|
| --- a/runtime/vm/thread_test.cc
|
| +++ b/runtime/vm/thread_test.cc
|
| @@ -435,28 +435,14 @@ TEST_CASE(ThreadIterator_Count) {
|
| }
|
|
|
|
|
| -static bool ThreadInList(Thread* thread) {
|
| - ThreadIterator it;
|
| - while (it.HasNext()) {
|
| - Thread* t = it.Next();
|
| - if (t == thread) {
|
| - return true;
|
| - }
|
| - }
|
| - return false;
|
| -}
|
| -
|
| -
|
| TEST_CASE(ThreadIterator_FindSelf) {
|
| Thread* current = Thread::Current();
|
| - EXPECT(ThreadInList(current));
|
| + EXPECT(Thread::IsThreadInList(current->join_id()));
|
| }
|
|
|
|
|
| struct ThreadIteratorTestParams {
|
| - Isolate* isolate;
|
| - Thread* spawned_thread;
|
| - ThreadJoinId spawned_thread_join_id;
|
| + ThreadId spawned_thread_join_id;
|
| Monitor* monitor;
|
| };
|
|
|
| @@ -465,54 +451,38 @@ void ThreadIteratorTestMain(uword parameter) {
|
| Thread::EnsureInit();
|
| ThreadIteratorTestParams* params =
|
| reinterpret_cast<ThreadIteratorTestParams*>(parameter);
|
| - Isolate* isolate = params->isolate;
|
| - EXPECT(isolate != NULL);
|
| Thread* thread = Thread::Current();
|
| EXPECT(thread != NULL);
|
|
|
| MonitorLocker ml(params->monitor);
|
| - params->spawned_thread = thread;
|
| - params->spawned_thread_join_id = OSThread::GetCurrentThreadJoinId();
|
| + params->spawned_thread_join_id = thread->join_id();
|
| EXPECT(params->spawned_thread_join_id != OSThread::kInvalidThreadJoinId);
|
| - EXPECT(ThreadInList(thread));
|
| + EXPECT(Thread::IsThreadInList(thread->join_id()));
|
| ml.Notify();
|
| }
|
|
|
|
|
| // NOTE: This test case also verifies that known TLS destructors are called
|
| -// on Windows. See |OnThreadExit| in os_thread_win.cc for more details.
|
| +// on Windows. See |OnDartThreadExit| in os_thread_win.cc for more details.
|
| TEST_CASE(ThreadIterator_AddFindRemove) {
|
| - Isolate* isolate = thread->isolate();
|
| ThreadIteratorTestParams params;
|
| - params.isolate = isolate;
|
| - params.spawned_thread = NULL;
|
| params.spawned_thread_join_id = OSThread::kInvalidThreadJoinId;
|
| params.monitor = new Monitor();
|
|
|
| {
|
| MonitorLocker ml(params.monitor);
|
| EXPECT(params.spawned_thread_join_id == OSThread::kInvalidThreadJoinId);
|
| - EXPECT(params.spawned_thread == NULL);
|
| // Spawn thread and wait to receive the thread join id.
|
| OSThread::Start(ThreadIteratorTestMain, reinterpret_cast<uword>(¶ms));
|
| while (params.spawned_thread_join_id == OSThread::kInvalidThreadJoinId) {
|
| ml.Wait();
|
| }
|
| EXPECT(params.spawned_thread_join_id != OSThread::kInvalidThreadJoinId);
|
| - EXPECT(params.spawned_thread != NULL);
|
| // Join thread.
|
| OSThread::Join(params.spawned_thread_join_id);
|
| }
|
|
|
| - for (intptr_t i = 0; i < 10; i++) {
|
| - // Sleep for 10 milliseconds.
|
| - OS::Sleep(10);
|
| - if (!ThreadInList(params.spawned_thread)) {
|
| - break;
|
| - }
|
| - }
|
| -
|
| - EXPECT(!ThreadInList(params.spawned_thread))
|
| + EXPECT(!Thread::IsThreadInList(params.spawned_thread_join_id))
|
|
|
| delete params.monitor;
|
| }
|
|
|