Changeset 225667 in webkit


Ignore:
Timestamp:
Dec 7, 2017 7:02:26 PM (6 years ago)
Author:
Yusuke Suzuki
Message:

Use WTF::RecursiveLockAdapter instead of using pthread_mutex_t with recursive lock option
https://bugs.webkit.org/show_bug.cgi?id=180449

Reviewed by Mark Lam.

Use WTF::RecursiveLockAdapter<StaticLock> instead. We can remove pthread_mutex_xxx,
pthread_once and FontLocker wrapper.

  • platform/graphics/FontCache.cpp:

(WebCore::FontCache::getCachedFontPlatformData):
(WebCore::FontCache::fontForPlatformData):
(WebCore::FontCache::purgeInactiveFontData):
(WebCore::FontCache::inactiveFontCount):
(initFontCacheLockOnce): Deleted.
(FontLocker::FontLocker): Deleted.
(FontLocker::~FontLocker): Deleted.

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r225663 r225667  
     12017-12-07  Yusuke Suzuki  <utatane.tea@gmail.com>
     2
     3        Use WTF::RecursiveLockAdapter instead of using pthread_mutex_t with recursive lock option
     4        https://bugs.webkit.org/show_bug.cgi?id=180449
     5
     6        Reviewed by Mark Lam.
     7
     8        Use WTF::RecursiveLockAdapter<StaticLock> instead. We can remove pthread_mutex_xxx,
     9        pthread_once and FontLocker wrapper.
     10
     11        * platform/graphics/FontCache.cpp:
     12        (WebCore::FontCache::getCachedFontPlatformData):
     13        (WebCore::FontCache::fontForPlatformData):
     14        (WebCore::FontCache::purgeInactiveFontData):
     15        (WebCore::FontCache::inactiveFontCount):
     16        (initFontCacheLockOnce): Deleted.
     17        (FontLocker::FontLocker): Deleted.
     18        (FontLocker::~FontLocker): Deleted.
     19
    1202017-12-07  Eric Carlson  <eric.carlson@apple.com>
    221
  • trunk/Source/WebCore/platform/graphics/FontCache.cpp

    r223476 r225667  
    5151
    5252#if PLATFORM(IOS)
    53 #include <wtf/Noncopyable.h>
    54 
    55 // FIXME: We may be able to simplify this code using C++11 threading primitives, including std::call_once().
    56 static pthread_mutex_t fontLock;
    57 
    58 static void initFontCacheLockOnce()
    59 {
    60     pthread_mutexattr_t mutexAttribute;
    61     pthread_mutexattr_init(&mutexAttribute);
    62     pthread_mutexattr_settype(&mutexAttribute, PTHREAD_MUTEX_RECURSIVE);
    63     pthread_mutex_init(&fontLock, &mutexAttribute);
    64     pthread_mutexattr_destroy(&mutexAttribute);
    65 }
    66 
    67 static pthread_once_t initFontLockControl = PTHREAD_ONCE_INIT;
    68 
    69 class FontLocker {
    70     WTF_MAKE_NONCOPYABLE(FontLocker);
    71 public:
    72     FontLocker()
    73     {
    74         pthread_once(&initFontLockControl, initFontCacheLockOnce);
    75         int lockcode = pthread_mutex_lock(&fontLock);
    76         ASSERT_WITH_MESSAGE_UNUSED(lockcode, !lockcode, "fontLock lock failed with code:%d", lockcode);   
    77     }
    78     ~FontLocker()
    79     {
    80         int lockcode = pthread_mutex_unlock(&fontLock);
    81         ASSERT_WITH_MESSAGE_UNUSED(lockcode, !lockcode, "fontLock unlock failed with code:%d", lockcode);
    82     }
    83 };
     53#include <wtf/Lock.h>
     54#include <wtf/RecursiveLockAdapter.h>
     55
     56using RecursiveStaticLock = WTF::RecursiveLockAdapter<StaticLock>;
     57static RecursiveStaticLock fontLock;
     58
    8459#endif // PLATFORM(IOS)
    8560
     
    233208{
    234209#if PLATFORM(IOS)
    235     FontLocker fontLocker;
     210    auto locker = holdLock(fontLock);
    236211#endif
    237212   
     
    361336{
    362337#if PLATFORM(IOS)
    363     FontLocker fontLocker;
     338    auto locker = holdLock(fontLock);
    364339#endif
    365340   
     
    394369
    395370#if PLATFORM(IOS)
    396     FontLocker fontLocker;
     371    auto locker = holdLock(fontLock);
    397372#endif
    398373
     
    438413{
    439414#if PLATFORM(IOS)
    440     FontLocker fontLocker;
     415    auto locker = holdLock(fontLock);
    441416#endif
    442417    unsigned count = 0;
Note: See TracChangeset for help on using the changeset viewer.