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

Side by Side Diff: runtime/vm/os_thread_win.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/os_thread_macos.cc ('k') | runtime/vm/port.cc » ('j') | 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/globals.h" // NOLINT 5 #include "platform/globals.h" // NOLINT
6 #if defined(TARGET_OS_WINDOWS) 6 #if defined(TARGET_OS_WINDOWS)
7 7
8 #include "vm/growable_array.h" 8 #include "vm/growable_array.h"
9 #include "vm/os_thread.h" 9 #include "vm/os_thread.h"
10 10
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 #if defined(DEBUG) 298 #if defined(DEBUG)
299 // When running with assertions enabled we track the owner. 299 // When running with assertions enabled we track the owner.
300 ASSERT(owner_ == OSThread::kInvalidThreadId); 300 ASSERT(owner_ == OSThread::kInvalidThreadId);
301 #endif // defined(DEBUG) 301 #endif // defined(DEBUG)
302 302
303 DeleteCriticalSection(&data_.cs_); 303 DeleteCriticalSection(&data_.cs_);
304 DeleteCriticalSection(&data_.waiters_cs_); 304 DeleteCriticalSection(&data_.waiters_cs_);
305 } 305 }
306 306
307 307
308 bool Mutex::TryEnter() {
309 // Attempt to pass the semaphore but return immediately.
310 BOOL result = TryEnterCriticalSection(&data_.cs_);
311 if (!result) {
312 return false;
313 }
314 #if defined(DEBUG)
315 // When running with assertions enabled we do track the owner.
316 ASSERT(owner_ == OSThread::kInvalidThreadId);
317 owner_ = OSThread::GetCurrentThreadId();
318 #endif // defined(DEBUG)
319 return true;
320 }
321
322
308 void Monitor::Enter() { 323 void Monitor::Enter() {
309 EnterCriticalSection(&data_.cs_); 324 EnterCriticalSection(&data_.cs_);
310 325
311 #if defined(DEBUG) 326 #if defined(DEBUG)
312 // When running with assertions enabled we track the owner. 327 // When running with assertions enabled we track the owner.
313 ASSERT(owner_ == OSThread::kInvalidThreadId); 328 ASSERT(owner_ == OSThread::kInvalidThreadId);
314 owner_ = OSThread::GetCurrentThreadId(); 329 owner_ = OSThread::GetCurrentThreadId();
315 #endif // defined(DEBUG) 330 #endif // defined(DEBUG)
316 } 331 }
317 332
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 #pragma data_seg(".CRT$XLB") 713 #pragma data_seg(".CRT$XLB")
699 PIMAGE_TLS_CALLBACK p_thread_callback_dart = OnDartThreadExit; 714 PIMAGE_TLS_CALLBACK p_thread_callback_dart = OnDartThreadExit;
700 715
701 // Reset the default section. 716 // Reset the default section.
702 #pragma data_seg() 717 #pragma data_seg()
703 718
704 #endif // _WIN64 719 #endif // _WIN64
705 } // extern "C" 720 } // extern "C"
706 721
707 #endif // defined(TARGET_OS_WINDOWS) 722 #endif // defined(TARGET_OS_WINDOWS)
OLDNEW
« no previous file with comments | « runtime/vm/os_thread_macos.cc ('k') | runtime/vm/port.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698