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

Side by Side Diff: runtime/vm/os_thread_android.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.h ('k') | runtime/vm/os_thread_linux.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_ANDROID) 6 #if defined(TARGET_OS_ANDROID)
7 7
8 #include "vm/os_thread.h" 8 #include "vm/os_thread.h"
9 9
10 #include <errno.h> // NOLINT 10 #include <errno.h> // NOLINT
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 #endif // defined(DEBUG) 329 #endif // defined(DEBUG)
330 330
331 int result = pthread_mutex_destroy(data_.mutex()); 331 int result = pthread_mutex_destroy(data_.mutex());
332 VALIDATE_PTHREAD_RESULT(result); 332 VALIDATE_PTHREAD_RESULT(result);
333 333
334 result = pthread_cond_destroy(data_.cond()); 334 result = pthread_cond_destroy(data_.cond());
335 VALIDATE_PTHREAD_RESULT(result); 335 VALIDATE_PTHREAD_RESULT(result);
336 } 336 }
337 337
338 338
339 bool Monitor::TryEnter() {
340 int result = pthread_mutex_trylock(data_.mutex());
341 // Return false if the lock is busy and locking failed.
342 if (result == EBUSY) {
343 return false;
344 }
345 ASSERT_PTHREAD_SUCCESS(result); // Verify no other errors.
346 #if defined(DEBUG)
347 // When running with assertions enabled we track the owner.
348 ASSERT(owner_ == OSThread::kInvalidThreadId);
349 owner_ = OSThread::GetCurrentThreadId();
350 #endif // defined(DEBUG)
351 return true;
352 }
353
354
339 void Monitor::Enter() { 355 void Monitor::Enter() {
340 int result = pthread_mutex_lock(data_.mutex()); 356 int result = pthread_mutex_lock(data_.mutex());
341 VALIDATE_PTHREAD_RESULT(result); 357 VALIDATE_PTHREAD_RESULT(result);
342 358
343 #if defined(DEBUG) 359 #if defined(DEBUG)
344 // When running with assertions enabled we track the owner. 360 // When running with assertions enabled we track the owner.
345 ASSERT(owner_ == OSThread::kInvalidThreadId); 361 ASSERT(owner_ == OSThread::kInvalidThreadId);
346 owner_ = OSThread::GetCurrentThreadId(); 362 owner_ = OSThread::GetCurrentThreadId();
347 #endif // defined(DEBUG) 363 #endif // defined(DEBUG)
348 } 364 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 void Monitor::NotifyAll() { 425 void Monitor::NotifyAll() {
410 // When running with assertions enabled we track the owner. 426 // When running with assertions enabled we track the owner.
411 ASSERT(IsOwnedByCurrentThread()); 427 ASSERT(IsOwnedByCurrentThread());
412 int result = pthread_cond_broadcast(data_.cond()); 428 int result = pthread_cond_broadcast(data_.cond());
413 VALIDATE_PTHREAD_RESULT(result); 429 VALIDATE_PTHREAD_RESULT(result);
414 } 430 }
415 431
416 } // namespace dart 432 } // namespace dart
417 433
418 #endif // defined(TARGET_OS_ANDROID) 434 #endif // defined(TARGET_OS_ANDROID)
OLDNEW
« no previous file with comments | « runtime/vm/os_thread.h ('k') | runtime/vm/os_thread_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698