mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:27:45 +00:00
AK: Add a Lockable wrapping container.
This commit is contained in:
parent
7e623e7ff2
commit
dabb3c902a
1 changed files with 14 additions and 0 deletions
14
AK/Lock.h
14
AK/Lock.h
|
@ -95,7 +95,21 @@ inline void Lock::unlock()
|
|||
|
||||
#define LOCKER(lock) Locker locker(lock)
|
||||
|
||||
template<typename T>
|
||||
class Lockable {
|
||||
public:
|
||||
Lockable() { }
|
||||
Lockable(T&& resource) : m_resource(move(resource)) { }
|
||||
Lock& lock() { return m_lock; }
|
||||
T& resource() { return m_resource; }
|
||||
|
||||
private:
|
||||
T m_resource;
|
||||
Lock m_lock;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
using AK::Lock;
|
||||
using AK::Locker;
|
||||
using AK::Lockable;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue