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

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

Issue 1748953003: - Add assertions in MutexLocker/MonitorLocker to ensure that the code enclosed (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: code-review-comments Created 4 years, 9 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 26 matching lines...) Expand all
37 37
38 UNIT_TEST_CASE(Monitor) { 38 UNIT_TEST_CASE(Monitor) {
39 // This unit test case needs a running isolate. 39 // This unit test case needs a running isolate.
40 Dart_CreateIsolate( 40 Dart_CreateIsolate(
41 NULL, NULL, bin::isolate_snapshot_buffer, NULL, NULL, NULL); 41 NULL, NULL, bin::isolate_snapshot_buffer, NULL, NULL, NULL);
42 OSThread* thread = OSThread::Current(); 42 OSThread* thread = OSThread::Current();
43 // Thread interrupter interferes with this test, disable interrupts. 43 // Thread interrupter interferes with this test, disable interrupts.
44 thread->DisableThreadInterrupts(); 44 thread->DisableThreadInterrupts();
45 Monitor* monitor = new Monitor(); 45 Monitor* monitor = new Monitor();
46 monitor->Enter(); 46 monitor->Enter();
47 EXPECT_EQ(false, monitor->TryEnter());
48 monitor->Exit();
49 EXPECT_EQ(true, monitor->TryEnter());
47 monitor->Exit(); 50 monitor->Exit();
48 51
49 const int kNumAttempts = 5; 52 const int kNumAttempts = 5;
50 int attempts = 0; 53 int attempts = 0;
51 while (attempts < kNumAttempts) { 54 while (attempts < kNumAttempts) {
52 MonitorLocker ml(monitor); 55 MonitorLocker ml(monitor);
53 int64_t start = OS::GetCurrentTimeMillis(); 56 int64_t start = OS::GetCurrentTimeMillis();
54 int64_t wait_time = 2017; 57 int64_t wait_time = 2017;
55 Monitor::WaitResult wait_result = ml.Wait(wait_time); 58 Monitor::WaitResult wait_result = ml.Wait(wait_time);
56 int64_t stop = OS::GetCurrentTimeMillis(); 59 int64_t stop = OS::GetCurrentTimeMillis();
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 TransitionVMToBlocked transition(thread); 572 TransitionVMToBlocked transition(thread);
570 MonitorLocker ml(&done_monitor); 573 MonitorLocker ml(&done_monitor);
571 if (done) { 574 if (done) {
572 break; 575 break;
573 } 576 }
574 } 577 }
575 } 578 }
576 } 579 }
577 580
578 } // namespace dart 581 } // 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