Changeset 248113 in webkit


Ignore:
Timestamp:
Aug 1, 2019 11:38:40 AM (5 years ago)
Author:
Chris Dumez
Message:

Add threading assertion to WeakPtr's operator->()
https://bugs.webkit.org/show_bug.cgi?id=199922

Reviewed by Ryosuke Niwa.

Add threading assertion to WeakPtr's operator->() to make sure that the WeakPtr
always gets dereferenced on the same thread it was constructed on.

  • wtf/WeakPtr.h:

(WTF::WeakPtrImpl::get):
(WTF::WeakPtrImpl::WeakPtrImpl):

Location:
trunk/Source/WTF
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r248071 r248113  
     12019-08-01  Chris Dumez  <cdumez@apple.com>
     2
     3        Add threading assertion to WeakPtr's operator->()
     4        https://bugs.webkit.org/show_bug.cgi?id=199922
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Add threading assertion to WeakPtr's operator->() to make sure that the WeakPtr
     9        always gets dereferenced on the same thread it was constructed on.
     10
     11        * wtf/WeakPtr.h:
     12        (WTF::WeakPtrImpl::get):
     13        (WTF::WeakPtrImpl::WeakPtrImpl):
     14
    1152019-07-31  Youenn Fablet  <youenn@apple.com>
    216
  • trunk/Source/WTF/wtf/WeakPtr.h

    r247425 r248113  
    6363    template<typename T> typename T::WeakValueType* get()
    6464    {
     65        // FIXME: We need to fix thread-safety bugs in WebCore and stop being more permissive for GC threads here.
     66        ASSERT(Thread::mayBeGCThread() || m_wasConstructedOnMainThread == isMainThread());
    6567        return static_cast<typename T::WeakValueType*>(m_ptr);
    6668    }
     
    7274    template<typename T> explicit WeakPtrImpl(T* ptr)
    7375        : m_ptr(static_cast<typename T::WeakValueType*>(ptr))
     76#if !ASSERT_DISABLED
     77        , m_wasConstructedOnMainThread(isMainThread())
     78#endif
    7479    {
    7580        DID_CREATE_WEAK_PTR_IMPL(ptr);
     
    7782
    7883    void* m_ptr;
     84#if !ASSERT_DISABLED
     85    bool m_wasConstructedOnMainThread;
     86#endif
    7987};
    8088
Note: See TracChangeset for help on using the changeset viewer.