mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-20 01:45:07 -04:00
kern: add abstract scoped lock template
This commit is contained in:
parent
57222e8301
commit
2355047715
5 changed files with 53 additions and 57 deletions
|
@ -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>;
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue