michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=8 sts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef LulRWLock_h michael@0: #define LulRWLock_h michael@0: michael@0: #include "LulPlatformMacros.h" michael@0: #include michael@0: michael@0: // This class provides a simple wrapper around reader-writer locks. michael@0: // This is necessary because Android 2.2's libpthread does not michael@0: // provide such functionality, so there has to be a way to provide michael@0: // an alternative with an equivalent interface. michael@0: michael@0: namespace lul { michael@0: michael@0: class LulRWLock { michael@0: michael@0: public: michael@0: LulRWLock(); michael@0: ~LulRWLock(); michael@0: void WrLock(); michael@0: void RdLock(); michael@0: void Unlock(); michael@0: michael@0: private: michael@0: #if defined(LUL_OS_android) michael@0: pthread_mutex_t mLock; michael@0: #elif defined(LUL_OS_linux) michael@0: pthread_rwlock_t mLock; michael@0: #else michael@0: # error "Unsupported OS" michael@0: #endif michael@0: michael@0: }; michael@0: michael@0: } // namespace lul michael@0: michael@0: #endif // LulRWLock_h