Chromium Code Reviews| Index: runtime/vm/thread_android.cc |
| =================================================================== |
| --- runtime/vm/thread_android.cc (revision 39381) |
| +++ runtime/vm/thread_android.cc (working copy) |
| @@ -11,6 +11,7 @@ |
| #include <sys/time.h> // NOLINT |
| #include "platform/assert.h" |
| +#include "vm/isolate.h" |
| namespace dart { |
| @@ -192,6 +193,12 @@ |
| result = pthread_mutexattr_destroy(&attr); |
| VALIDATE_PTHREAD_RESULT(result); |
| + |
| + // When running with assertions enabled we do track the owner. |
| +#if defined(DEBUG) |
| + ASSERT(owner_ == Isolate::Current()); |
|
siva
2014/08/20 17:21:23
How does this assert work?
owner_ field has not be
Ivan Posva
2014/08/20 18:35:20
Done. Thanks!
|
| + owner_ = NULL; |
| +#endif // defined(DEBUG) |
| } |
| @@ -199,6 +206,11 @@ |
| int result = pthread_mutex_destroy(data_.mutex()); |
| // Verify that the pthread_mutex was destroyed. |
| VALIDATE_PTHREAD_RESULT(result); |
| + |
| + // When running with assertions enabled we do track the owner. |
| +#if defined(DEBUG) |
| + ASSERT(owner_ == NULL); |
| +#endif // defined(DEBUG) |
| } |
| @@ -207,7 +219,10 @@ |
| // Specifically check for dead lock to help debugging. |
| ASSERT(result != EDEADLK); |
| ASSERT(result == 0); // Verify no other errors. |
| - // TODO(iposva): Do we need to track lock owners? |
| + // When running with assertions enabled we do track the owner. |
| +#if defined(DEBUG) |
| + owner_ = Isolate::Current(); |
| +#endif // defined(DEBUG) |
| } |
| @@ -218,13 +233,20 @@ |
| return false; |
| } |
| ASSERT(result == 0); // Verify no other errors. |
| - // TODO(iposva): Do we need to track lock owners? |
| + // When running with assertions enabled we do track the owner. |
| +#if defined(DEBUG) |
| + owner_ = Isolate::Current(); |
| +#endif // defined(DEBUG) |
| return true; |
| } |
| void Mutex::Unlock() { |
| - // TODO(iposva): Do we need to track lock owners? |
| + // When running with assertions enabled we do track the owner. |
| +#if defined(DEBUG) |
| + ASSERT(owner_ == Isolate::Current()); |
| + owner_ = NULL; |
| +#endif // defined(DEBUG) |
| int result = pthread_mutex_unlock(data_.mutex()); |
| // Specifically check for wrong thread unlocking to aid debugging. |
| ASSERT(result != EPERM); |