Changeset 248544 in webkit


Ignore:
Timestamp:
Aug 12, 2019 1:15:26 PM (5 years ago)
Author:
Chris Dumez
Message:

Unreviewed, fix post landing review comments for r248533 from Darin.

  • wtf/RefCounted.h:

(WTF::RefCountedBase::ref const):
(WTF::RefCountedBase::applyRefDerefThreadingCheck const):
(WTF::RefCountedBase::derefBase const):
(WTF::RefCountedBase::areThreadingCheckedEnabled const): Deleted.

Location:
trunk/Source/WTF
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r248533 r248544  
     12019-08-12  Chris Dumez  <cdumez@apple.com>
     2
     3        Unreviewed, fix post landing review comments for r248533 from Darin.
     4
     5        * wtf/RefCounted.h:
     6        (WTF::RefCountedBase::ref const):
     7        (WTF::RefCountedBase::applyRefDerefThreadingCheck const):
     8        (WTF::RefCountedBase::derefBase const):
     9        (WTF::RefCountedBase::areThreadingCheckedEnabled const): Deleted.
     10
    1112019-08-12  Chris Dumez  <cdumez@apple.com>
    212
  • trunk/Source/WTF/wtf/RefCounted.h

    r248533 r248544  
    4141    void ref() const
    4242    {
    43 #if !ASSERT_DISABLED
    44         if (m_isOwnedByMainThread != isMainThread() && hasOneRef())
    45             m_isOwnedByMainThread = isMainThread(); // Likely ownership transfer.
    46 
    47         // If you hit this assertion, it means that the RefCounted object was ref'd or deref'd
    48         // concurrent from several threads, which is not safe. You should either subclass
    49         // ThreadSafeRefCounted instead, or make sure to always ref / deref from the same thread.
    50         ASSERT_WITH_MESSAGE(!areThreadingCheckedEnabled() || m_isOwnedByMainThread == isMainThread(), "Should not be ref'd / deref'd concurrently from several threads");
    51 #endif
     43        applyRefDerefThreadingCheck();
    5244
    5345#if CHECK_REF_COUNTED_LIFECYCLE
     
    109101    }
    110102
    111 #if !ASSERT_DISABLED
    112     bool areThreadingCheckedEnabled() const
    113     {
    114         return areThreadingChecksEnabledGlobally && m_areThreadingChecksEnabled;
    115     }
    116 #endif
     103    void applyRefDerefThreadingCheck() const
     104    {
     105#if !ASSERT_DISABLED
     106        if (hasOneRef()) {
     107            // Likely an ownership transfer across threads that may be safe.
     108            m_isOwnedByMainThread = isMainThread();
     109        } else if (areThreadingChecksEnabledGlobally && m_areThreadingChecksEnabled) {
     110            // If you hit this assertion, it means that the RefCounted object was ref/deref'd
     111            // from both the main thread and another in a way that is likely concurrent and unsafe.
     112            // Derive from ThreadSafeRefCounted and make sure the destructor is safe on threads
     113            // that call deref, or ref/deref from a single thread.
     114            ASSERT_WITH_MESSAGE(m_isOwnedByMainThread == isMainThread(), "Unsafe to ref/deref from different threads");
     115        }
     116#endif
     117    }
    117118
    118119    ~RefCountedBase()
     
    127128    bool derefBase() const
    128129    {
    129 #if !ASSERT_DISABLED
    130         if (m_isOwnedByMainThread != isMainThread() && hasOneRef())
    131             m_isOwnedByMainThread = isMainThread(); // Likely ownership transfer.
    132 
    133         // If you hit this assertion, it means that the RefCounted object was ref'd or deref'd
    134         // concurrent from several threads, which is not safe. You should either subclass
    135         // ThreadSafeRefCounted instead, or make sure to always ref / deref from the same thread.
    136         ASSERT_WITH_MESSAGE(!areThreadingCheckedEnabled() || m_isOwnedByMainThread == isMainThread(), "Should not be ref'd / deref'd concurrently from several threads");
    137 #endif
     130        applyRefDerefThreadingCheck();
    138131
    139132#if CHECK_REF_COUNTED_LIFECYCLE
Note: See TracChangeset for help on using the changeset viewer.