blob: 749fb5d0bde250038ff0e40aa492efa9d53e3179 [file] [log] [blame]
Ian Rogers22d5e732014-07-15 22:23:51 -07001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "object_lock.h"
18
19#include "mirror/object-inl.h"
20#include "monitor.h"
21
22namespace art {
23
24template <typename T>
Andreas Gampe5a4b8a22014-09-11 08:30:08 -070025ObjectLock<T>::ObjectLock(Thread* self, Handle<T> object) : self_(self), obj_(object) {
Ian Rogers22d5e732014-07-15 22:23:51 -070026 CHECK(object.Get() != nullptr);
27 obj_->MonitorEnter(self_);
28}
29
30template <typename T>
31ObjectLock<T>::~ObjectLock() {
32 obj_->MonitorExit(self_);
33}
34
35template <typename T>
36void ObjectLock<T>::WaitIgnoringInterrupts() {
37 Monitor::Wait(self_, obj_.Get(), 0, 0, false, kWaiting);
38}
39
40template <typename T>
41void ObjectLock<T>::Notify() {
42 obj_->Notify(self_);
43}
44
45template <typename T>
46void ObjectLock<T>::NotifyAll() {
47 obj_->NotifyAll(self_);
48}
49
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080050template class ObjectLock<mirror::ArtMethod>;
Ian Rogers22d5e732014-07-15 22:23:51 -070051template class ObjectLock<mirror::Class>;
52template class ObjectLock<mirror::Object>;
53
54} // namespace art