Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(304)

Side by Side Diff: runtime/vm/thread_test.cc

Issue 1978153002: Uses an open thread handle as the ThreadJoinId on Windows. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix test Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/thread_pool.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/assert.h" 5 #include "platform/assert.h"
6 #include "vm/isolate.h" 6 #include "vm/isolate.h"
7 #include "vm/lockers.h" 7 #include "vm/lockers.h"
8 #include "vm/unit_test.h" 8 #include "vm/unit_test.h"
9 #include "vm/profiler.h" 9 #include "vm/profiler.h"
10 #include "vm/safepoint.h" 10 #include "vm/safepoint.h"
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 } 428 }
429 429
430 EXPECT(thread_count_0 > 0); 430 EXPECT(thread_count_0 > 0);
431 EXPECT(thread_count_1 > 0); 431 EXPECT(thread_count_1 > 0);
432 EXPECT(thread_count_0 >= thread_count_1); 432 EXPECT(thread_count_0 >= thread_count_1);
433 } 433 }
434 434
435 435
436 VM_TEST_CASE(ThreadIterator_FindSelf) { 436 VM_TEST_CASE(ThreadIterator_FindSelf) {
437 OSThread* current = OSThread::Current(); 437 OSThread* current = OSThread::Current();
438 EXPECT(OSThread::IsThreadInList(current->join_id())); 438 EXPECT(OSThread::IsThreadInList(current->id()));
439 } 439 }
440 440
441 441
442 struct ThreadIteratorTestParams { 442 struct ThreadIteratorTestParams {
443 ThreadId spawned_thread_join_id; 443 ThreadId spawned_thread_id;
444 ThreadJoinId spawned_thread_join_id;
444 Monitor* monitor; 445 Monitor* monitor;
445 }; 446 };
446 447
447 448
448 void ThreadIteratorTestMain(uword parameter) { 449 void ThreadIteratorTestMain(uword parameter) {
449 ThreadIteratorTestParams* params = 450 ThreadIteratorTestParams* params =
450 reinterpret_cast<ThreadIteratorTestParams*>(parameter); 451 reinterpret_cast<ThreadIteratorTestParams*>(parameter);
451 OSThread* thread = OSThread::Current(); 452 OSThread* thread = OSThread::Current();
452 EXPECT(thread != NULL); 453 EXPECT(thread != NULL);
453 454
454 MonitorLocker ml(params->monitor); 455 MonitorLocker ml(params->monitor);
455 params->spawned_thread_join_id = thread->join_id(); 456 params->spawned_thread_id = thread->id();
456 EXPECT(params->spawned_thread_join_id != OSThread::kInvalidThreadJoinId); 457 params->spawned_thread_join_id = OSThread::GetCurrentThreadJoinId(thread);
457 EXPECT(OSThread::IsThreadInList(thread->join_id())); 458 EXPECT(params->spawned_thread_id != OSThread::kInvalidThreadId);
459 EXPECT(OSThread::IsThreadInList(thread->id()));
458 ml.Notify(); 460 ml.Notify();
459 } 461 }
460 462
461 463
462 // NOTE: This test case also verifies that known TLS destructors are called 464 // NOTE: This test case also verifies that known TLS destructors are called
463 // on Windows. See |OnDartThreadExit| in os_thread_win.cc for more details. 465 // on Windows. See |OnDartThreadExit| in os_thread_win.cc for more details.
464 TEST_CASE(ThreadIterator_AddFindRemove) { 466 TEST_CASE(ThreadIterator_AddFindRemove) {
465 ThreadIteratorTestParams params; 467 ThreadIteratorTestParams params;
466 params.spawned_thread_join_id = OSThread::kInvalidThreadJoinId; 468 params.spawned_thread_id = OSThread::kInvalidThreadId;
467 params.monitor = new Monitor(); 469 params.monitor = new Monitor();
468 470
469 { 471 {
470 MonitorLocker ml(params.monitor); 472 MonitorLocker ml(params.monitor);
471 EXPECT(params.spawned_thread_join_id == OSThread::kInvalidThreadJoinId); 473 EXPECT(params.spawned_thread_id == OSThread::kInvalidThreadId);
472 // Spawn thread and wait to receive the thread join id. 474 // Spawn thread and wait to receive the thread id.
473 OSThread::Start("ThreadIteratorTest", 475 OSThread::Start("ThreadIteratorTest",
474 ThreadIteratorTestMain, 476 ThreadIteratorTestMain,
475 reinterpret_cast<uword>(&params)); 477 reinterpret_cast<uword>(&params));
476 while (params.spawned_thread_join_id == OSThread::kInvalidThreadJoinId) { 478 while (params.spawned_thread_id == OSThread::kInvalidThreadId) {
477 ml.Wait(); 479 ml.Wait();
478 } 480 }
481 EXPECT(params.spawned_thread_id != OSThread::kInvalidThreadId);
479 EXPECT(params.spawned_thread_join_id != OSThread::kInvalidThreadJoinId); 482 EXPECT(params.spawned_thread_join_id != OSThread::kInvalidThreadJoinId);
480 // Join thread.
481 OSThread::Join(params.spawned_thread_join_id); 483 OSThread::Join(params.spawned_thread_join_id);
482 } 484 }
483 485
484 EXPECT(!OSThread::IsThreadInList(params.spawned_thread_join_id)) 486 EXPECT(!OSThread::IsThreadInList(params.spawned_thread_id))
485 487
486 delete params.monitor; 488 delete params.monitor;
487 } 489 }
488 490
489 491
490 // Test rendezvous of: 492 // Test rendezvous of:
491 // - helpers in VM code, and 493 // - helpers in VM code, and
492 // - main thread in VM code, 494 // - main thread in VM code,
493 // organized by 495 // organized by
494 // - main thread, and 496 // - main thread, and
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 TransitionVMToBlocked transition(thread); 573 TransitionVMToBlocked transition(thread);
572 MonitorLocker ml(&done_monitor); 574 MonitorLocker ml(&done_monitor);
573 if (done) { 575 if (done) {
574 break; 576 break;
575 } 577 }
576 } 578 }
577 } 579 }
578 } 580 }
579 581
580 } // namespace dart 582 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/thread_pool.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698