1 // Copyright 2013 The Flutter Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "flutter/fml/platform/posix/shared_mutex_posix.h" 6 #include "flutter/fml/logging.h" 7 8 namespace fml { 9 Create()10SharedMutex* SharedMutex::Create() { 11 return new SharedMutexPosix(); 12 } 13 SharedMutexPosix()14SharedMutexPosix::SharedMutexPosix() { 15 FML_CHECK(pthread_rwlock_init(&rwlock_, nullptr) == 0); 16 } 17 Lock()18void SharedMutexPosix::Lock() { 19 pthread_rwlock_wrlock(&rwlock_); 20 } 21 LockShared()22void SharedMutexPosix::LockShared() { 23 pthread_rwlock_rdlock(&rwlock_); 24 } 25 Unlock()26void SharedMutexPosix::Unlock() { 27 pthread_rwlock_unlock(&rwlock_); 28 } 29 UnlockShared()30void SharedMutexPosix::UnlockShared() { 31 pthread_rwlock_unlock(&rwlock_); 32 } 33 34 } // namespace fml 35