Files
sdk/runtime/bin/lockers.h
T
Zachary Anderson 103881d01c Make header include guards great again
i.e. #ifndef VM_WHATEVER -> #ifndef RUNTIME_VM_WHATEVER

This lets us remove a hack from the PRESUBMIT.py script that existed
for reasons that are no longer valid, and sets us up to add some
presubmit checks for the GN build.

R=asiva@google.com, rmacnak@google.com

Review URL: https://codereview.chromium.org/2450713004 .
2016-10-26 00:26:03 -07:00

65 lines
1.2 KiB
C++

// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#ifndef RUNTIME_BIN_LOCKERS_H_
#define RUNTIME_BIN_LOCKERS_H_
#include "bin/thread.h"
#include "platform/assert.h"
namespace dart {
namespace bin {
class MutexLocker {
public:
explicit MutexLocker(Mutex* mutex) : mutex_(mutex) {
ASSERT(mutex != NULL);
mutex_->Lock();
}
virtual ~MutexLocker() {
mutex_->Unlock();
}
private:
Mutex* const mutex_;
DISALLOW_COPY_AND_ASSIGN(MutexLocker);
};
class MonitorLocker {
public:
explicit MonitorLocker(Monitor* monitor) : monitor_(monitor) {
ASSERT(monitor != NULL);
monitor_->Enter();
}
virtual ~MonitorLocker() {
monitor_->Exit();
}
Monitor::WaitResult Wait(int64_t millis = Monitor::kNoTimeout) {
return monitor_->Wait(millis);
}
void Notify() {
monitor_->Notify();
}
void NotifyAll() {
monitor_->NotifyAll();
}
private:
Monitor* const monitor_;
DISALLOW_COPY_AND_ASSIGN(MonitorLocker);
};
} // namespace bin
} // namespace dart
#endif // RUNTIME_BIN_LOCKERS_H_