[Lldb-commits] [lldb] r252031 - Add a few useful methods to ThreadSafeDense{Map, Set}. Not used yet.

Zachary Turner via lldb-commits lldb-commits at lists.llvm.org
Tue Nov 3 17:43:46 PST 2015


Seems like this class would be a good candidate for using an RWMutex.  Any
reason you can think of why that wouldn't work?

On Tue, Nov 3, 2015 at 5:41 PM Jim Ingham via lldb-commits <
lldb-commits at lists.llvm.org> wrote:

> Author: jingham
> Date: Tue Nov  3 19:39:05 2015
> New Revision: 252031
>
> URL: http://llvm.org/viewvc/llvm-project?rev=252031&view=rev
> Log:
> Add a few useful methods to ThreadSafeDense{Map,Set}.  Not used yet.
>
> Modified:
>     lldb/trunk/include/lldb/Core/ThreadSafeDenseMap.h
>     lldb/trunk/include/lldb/Core/ThreadSafeDenseSet.h
>
> Modified: lldb/trunk/include/lldb/Core/ThreadSafeDenseMap.h
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ThreadSafeDenseMap.h?rev=252031&r1=252030&r2=252031&view=diff
>
> ==============================================================================
> --- lldb/trunk/include/lldb/Core/ThreadSafeDenseMap.h (original)
> +++ lldb/trunk/include/lldb/Core/ThreadSafeDenseMap.h Tue Nov  3 19:39:05
> 2015
> @@ -54,7 +54,27 @@ public:
>          Mutex::Locker locker(m_mutex);
>          return m_map.lookup(k);
>      }
> -
> +
> +    bool
> +    Lookup (_KeyType k,
> +            _ValueType& v)
> +    {
> +        Mutex::Locker locker(m_mutex);
> +        auto iter = m_map.find(k),
> +             end = m_map.end();
> +        if (iter == end)
> +            return false;
> +        v = iter->second;
> +        return true;
> +    }
> +
> +    void
> +    Clear ()
> +    {
> +        Mutex::Locker locker(m_mutex);
> +        m_map.clear();
> +    }
> +
>  protected:
>      LLVMMapType m_map;
>      Mutex m_mutex;
>
> Modified: lldb/trunk/include/lldb/Core/ThreadSafeDenseSet.h
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ThreadSafeDenseSet.h?rev=252031&r1=252030&r2=252031&view=diff
>
> ==============================================================================
> --- lldb/trunk/include/lldb/Core/ThreadSafeDenseSet.h (original)
> +++ lldb/trunk/include/lldb/Core/ThreadSafeDenseSet.h Tue Nov  3 19:39:05
> 2015
> @@ -55,6 +55,13 @@ namespace lldb_private {
>              return (m_set.count(e) > 0);
>          }
>
> +        void
> +        Clear ()
> +        {
> +            Mutex::Locker locker(m_mutex);
> +            m_set.clear();
> +        }
> +
>      protected:
>          LLVMSetType m_set;
>          Mutex m_mutex;
>
>
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20151104/2a54c86c/attachment.html>


More information about the lldb-commits mailing list