WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
184442
Bmalloc should have its own lockers instead of lock_guard and unique_lock
https://bugs.webkit.org/show_bug.cgi?id=184442
Summary
Bmalloc should have its own lockers instead of lock_guard and unique_lock
Saam Barati
Reported
2018-04-09 22:55:30 PDT
std::unique_lock and std::lock_guard are incompatible types. With
bug #184176
, I need to use unique_lock in just a few places since we may drop it to wait on a condition variable. However, since we pass this locker to things we call, I need to change the function of a bunch of signatures that don't actually need the API unique_lock provides. Same with things that call this API, they now need to pass in unique_lock. A lot less code would be changed if we just had a class hierarchy like this: ``` // I'm just picking same names as std, but we could do something different. template <typename Lock> class LockGuard { public: LockGuard(Lock& lock) : m_lock(lock) { m_lock.lock(); } ~LockGuard(Lock& lock) { if (m_locked) m_lock.unlock(); } protected: Lock& m_lock; bool m_locked { true }; }; template <typename Lock> class UniqueLock : public LockGuard<Lock> { using Base = LockGuard<Lock>; public: UniqueLock(Lock& l) : Base(l) { } void lock() { m_locked = true; m_lock.lock(); } void unlock() { m_locked = false; m_lock.unlock(); } }; ``` Or something along those lines.
Attachments
Add attachment
proposed patch, testcase, etc.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug