mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
AK: Add a Lockable wrapping container.
This commit is contained in:
parent
7e623e7ff2
commit
dabb3c902a
Notes:
sideshowbarker
2024-07-19 15:49:44 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/dabb3c902ab
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…
Reference in a new issue