<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>184442</bug_id>
          
          <creation_ts>2018-04-09 22:55:30 -0700</creation_ts>
          <short_desc>Bmalloc should have its own lockers instead of lock_guard and unique_lock</short_desc>
          <delta_ts>2018-04-09 22:55:46 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>JavaScriptCore</component>
          <version>Safari Technology Preview</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>184176</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Saam Barati">saam</reporter>
          <assigned_to name="Saam Barati">saam</assigned_to>
          <cc>benjamin</cc>
    
    <cc>fpizlo</cc>
    
    <cc>ggaren</cc>
    
    <cc>gskachkov</cc>
    
    <cc>jfbastien</cc>
    
    <cc>keith_miller</cc>
    
    <cc>mark.lam</cc>
    
    <cc>msaboff</cc>
    
    <cc>rmorisset</cc>
    
    <cc>ticaiolima</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1413206</commentid>
    <comment_count>0</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2018-04-09 22:55:30 -0700</bug_when>
    <thetext>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&apos;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&apos;m just picking same names as std, but we could do something different.
template &lt;typename Lock&gt;
class LockGuard {
public:
    LockGuard(Lock&amp; lock) 
        : m_lock(lock)
   {
       m_lock.lock();
   }
   ~LockGuard(Lock&amp; lock)
   {
       if (m_locked)
           m_lock.unlock();
   }
protected:
    Lock&amp; m_lock;
    bool m_locked { true };
};

template &lt;typename Lock&gt;
class UniqueLock : public LockGuard&lt;Lock&gt; {
    using Base = LockGuard&lt;Lock&gt;;
public:
    UniqueLock(Lock&amp; l) : Base(l) { }
    void lock() { m_locked = true; m_lock.lock(); }
    void unlock() { m_locked = false; m_lock.unlock(); }
};
```

Or something along those lines.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>