Changeset 118587 in webkit


Ignore:
Timestamp:
May 25, 2012 4:46:28 PM (12 years ago)
Author:
mitz@apple.com
Message:

Make the ICU-based implementation of NonSharedCharacterBreakIterator work in configurations
that do not have COMPARE_AND_SWAP enabled.

Reviewed by Jessie Berlin.

  • platform/text/TextBreakIteratorICU.cpp:

(WebCore::compareAndSwapNonSharedCharacterBreakIterator): Added this helper. It uses
weakCompareAndSwap when COMPARE_AND_SWAP is enabled, and uses a mutex to do the atomic
compare and swap otherwise.
(WebCore::NonSharedCharacterBreakIterator::NonSharedCharacterBreakIterator): Changed to use
compareAndSwapNonSharedCharacterBreakIterator().
(WebCore::NonSharedCharacterBreakIterator::~NonSharedCharacterBreakIterator): Ditto.

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r118586 r118587  
     12012-05-25  Dan Bernstein  <mitz@apple.com>
     2
     3        Make the ICU-based implementation of NonSharedCharacterBreakIterator work in configurations
     4        that do not have COMPARE_AND_SWAP enabled.
     5
     6        Reviewed by Jessie Berlin.
     7
     8        * platform/text/TextBreakIteratorICU.cpp:
     9        (WebCore::compareAndSwapNonSharedCharacterBreakIterator): Added this helper. It uses
     10        weakCompareAndSwap when COMPARE_AND_SWAP is enabled, and uses a mutex to do the atomic
     11        compare and swap otherwise.
     12        (WebCore::NonSharedCharacterBreakIterator::NonSharedCharacterBreakIterator): Changed to use
     13        compareAndSwapNonSharedCharacterBreakIterator().
     14        (WebCore::NonSharedCharacterBreakIterator::~NonSharedCharacterBreakIterator): Ditto.
     15
    1162012-05-25  Tommy Widenflycht  <tommyw@google.com>
    217
  • trunk/Source/WebCore/platform/text/TextBreakIteratorICU.cpp

    r118568 r118587  
    8888static TextBreakIterator* nonSharedCharacterBreakIterator;
    8989
     90static inline bool compareAndSwapNonSharedCharacterBreakIterator(TextBreakIterator* expected, TextBreakIterator* newValue)
     91{
     92#if ENABLE(COMPARE_AND_SWAP)
     93    return weakCompareAndSwap(reinterpret_cast<void**>(&nonSharedCharacterBreakIterator), expected, newValue);
     94#else
     95    DEFINE_STATIC_LOCAL(Mutex, nonSharedCharacterBreakIteratorMutex, ());
     96    MutexLocker locker(nonSharedCharacterBreakIteratorMutex);
     97    if (nonSharedCharacterBreakIterator != expected)
     98        return false;
     99    nonSharedCharacterBreakIterator = newValue;
     100    return true;
     101#endif
     102}
     103
    90104NonSharedCharacterBreakIterator::NonSharedCharacterBreakIterator(const UChar* buffer, int length)
    91105{
    92106    m_iterator = nonSharedCharacterBreakIterator;
    93     bool createdIterator = m_iterator && weakCompareAndSwap(reinterpret_cast<void**>(&nonSharedCharacterBreakIterator), m_iterator, 0);
     107    bool createdIterator = m_iterator && compareAndSwapNonSharedCharacterBreakIterator(m_iterator, 0);
    94108    m_iterator = setUpIterator(createdIterator, m_iterator, UBRK_CHARACTER, buffer, length);
    95109}
     
    97111NonSharedCharacterBreakIterator::~NonSharedCharacterBreakIterator()
    98112{
    99     if (!weakCompareAndSwap(reinterpret_cast<void**>(&nonSharedCharacterBreakIterator), 0, m_iterator))
     113    if (!compareAndSwapNonSharedCharacterBreakIterator(0, m_iterator))
    100114        ubrk_close(reinterpret_cast<UBreakIterator*>(m_iterator));
    101115}
Note: See TracChangeset for help on using the changeset viewer.