kern: add abstract scoped lock template

This commit is contained in:
Michael Scire 2020-01-31 16:37:58 -08:00
parent 57222e8301
commit 2355047715
5 changed files with 53 additions and 57 deletions

View file

@ -17,6 +17,7 @@
#include <mesosphere/kern_common.hpp>
#include <mesosphere/kern_select_cpu.hpp>
#include <mesosphere/kern_k_current_context.hpp>
#include <mesosphere/kern_k_scoped_lock.hpp>
namespace ams::kern {
@ -60,18 +61,6 @@ namespace ams::kern {
void UnlockSlowPath(uintptr_t cur_thread);
};
class KScopedLightLock {
private:
KLightLock *lock;
public:
explicit ALWAYS_INLINE KScopedLightLock(KLightLock *l) : lock(l) {
this->lock->Lock();
}
ALWAYS_INLINE ~KScopedLightLock() {
this->lock->Unlock();
}
explicit ALWAYS_INLINE KScopedLightLock(KLightLock &l) : KScopedLightLock(std::addressof(l)) { /* ... */ }
};
using KScopedLightLock = KScopedLock<KLightLock>;
}