/*
 * Copyright (C) 2011 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "object_lock.h"

#include "mirror/class_ext.h"
#include "mirror/object-inl.h"
#include "monitor.h"

namespace art HIDDEN {

template <typename T>
ObjectLock<T>::ObjectLock(Thread* self, Handle<T> object) : self_(self), obj_(object) {
  CHECK(object != nullptr);
  obj_->MonitorEnter(self_);
}

template <typename T>
ObjectLock<T>::~ObjectLock() {
  obj_->MonitorExit(self_);
}

template <typename T>
void ObjectLock<T>::WaitIgnoringInterrupts() {
  Monitor::Wait(self_, obj_.Get(), 0, 0, false, ThreadState::kWaiting);
}

template <typename T>
void ObjectLock<T>::Notify() {
  obj_->Notify(self_);
}

template <typename T>
void ObjectLock<T>::NotifyAll() {
  obj_->NotifyAll(self_);
}

template <typename T>
ObjectTryLock<T>::ObjectTryLock(Thread* self, Handle<T> object) : self_(self), obj_(object) {
  CHECK(object != nullptr);
  acquired_ = obj_->MonitorTryEnter(self_) != nullptr;
}

template <typename T>
ObjectTryLock<T>::~ObjectTryLock() {
  if (acquired_) {
    obj_->MonitorExit(self_);
  }
}

template class ObjectLock<mirror::Class>;
template class ObjectLock<mirror::ClassExt>;
template class ObjectLock<mirror::Object>;
template class ObjectTryLock<mirror::Class>;
template class ObjectTryLock<mirror::Object>;

}  // namespace art
