Changeset 118587 in webkit
- Timestamp:
- May 25, 2012 4:46:28 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r118586 r118587 1 2012-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 1 16 2012-05-25 Tommy Widenflycht <tommyw@google.com> 2 17 -
trunk/Source/WebCore/platform/text/TextBreakIteratorICU.cpp
r118568 r118587 88 88 static TextBreakIterator* nonSharedCharacterBreakIterator; 89 89 90 static 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 90 104 NonSharedCharacterBreakIterator::NonSharedCharacterBreakIterator(const UChar* buffer, int length) 91 105 { 92 106 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); 94 108 m_iterator = setUpIterator(createdIterator, m_iterator, UBRK_CHARACTER, buffer, length); 95 109 } … … 97 111 NonSharedCharacterBreakIterator::~NonSharedCharacterBreakIterator() 98 112 { 99 if (! weakCompareAndSwap(reinterpret_cast<void**>(&nonSharedCharacterBreakIterator),0, m_iterator))113 if (!compareAndSwapNonSharedCharacterBreakIterator(0, m_iterator)) 100 114 ubrk_close(reinterpret_cast<UBreakIterator*>(m_iterator)); 101 115 }
Note: See TracChangeset
for help on using the changeset viewer.