1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/tools/profiler/LulRWLock.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,42 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef LulRWLock_h 1.11 +#define LulRWLock_h 1.12 + 1.13 +#include "LulPlatformMacros.h" 1.14 +#include <pthread.h> 1.15 + 1.16 +// This class provides a simple wrapper around reader-writer locks. 1.17 +// This is necessary because Android 2.2's libpthread does not 1.18 +// provide such functionality, so there has to be a way to provide 1.19 +// an alternative with an equivalent interface. 1.20 + 1.21 +namespace lul { 1.22 + 1.23 +class LulRWLock { 1.24 + 1.25 +public: 1.26 + LulRWLock(); 1.27 + ~LulRWLock(); 1.28 + void WrLock(); 1.29 + void RdLock(); 1.30 + void Unlock(); 1.31 + 1.32 +private: 1.33 +#if defined(LUL_OS_android) 1.34 + pthread_mutex_t mLock; 1.35 +#elif defined(LUL_OS_linux) 1.36 + pthread_rwlock_t mLock; 1.37 +#else 1.38 +# error "Unsupported OS" 1.39 +#endif 1.40 + 1.41 +}; 1.42 + 1.43 +} // namespace lul 1.44 + 1.45 +#endif // LulRWLock_h