diff options
| author | 2012-01-12 18:14:32 -0800 | |
|---|---|---|
| committer | 2012-01-12 18:14:32 -0800 | |
| commit | 4004b36bf6dfae095092ed4579c5ad6e4198fc30 (patch) | |
| tree | ac0750968981ad5cf7449ddcc7c1b39e847d054c /src/object_utils.h | |
| parent | d9c37b307713572b6ea32e9f6ff965d15b3f4b88 (diff) | |
| parent | 672f520b125639c090cc38c9ae7231e0dfbd31dd (diff) | |
Merge "Fix race in double verifying super class" into dalvik-dev
Diffstat (limited to 'src/object_utils.h')
| -rw-r--r-- | src/object_utils.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/object_utils.h b/src/object_utils.h index f9aca10e65..0412858084 100644 --- a/src/object_utils.h +++ b/src/object_utils.h @@ -21,6 +21,7 @@ #include "dex_cache.h" #include "dex_file.h" #include "intern_table.h" +#include "monitor.h" #include "object.h" #include "runtime.h" #include "UniquePtr.h" @@ -29,6 +30,35 @@ namespace art { +class ObjectLock { + public: + explicit ObjectLock(Object* object) : self_(Thread::Current()), obj_(object) { + CHECK(object != NULL); + obj_->MonitorEnter(self_); + } + + ~ObjectLock() { + obj_->MonitorExit(self_); + } + + void Wait() { + return Monitor::Wait(self_, obj_, 0, 0, false); + } + + void Notify() { + obj_->Notify(); + } + + void NotifyAll() { + obj_->NotifyAll(); + } + + private: + Thread* self_; + Object* obj_; + DISALLOW_COPY_AND_ASSIGN(ObjectLock); +}; + class ClassHelper { public: ClassHelper(const Class* c = NULL, ClassLinker* l = NULL) |