summaryrefslogtreecommitdiff
path: root/system_wrappers
diff options
context:
space:
mode:
authorphoglund@webrtc.org <phoglund@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d>2012-12-18 15:20:35 +0000
committerphoglund@webrtc.org <phoglund@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d>2012-12-18 15:20:35 +0000
commitba41365cf8e326bff31b693ddef75ba1c38c23a0 (patch)
tree6ac0c35add6086ab1648b498c6850ae67cd70f48 /system_wrappers
parent604f213cc5f84834035feed6bb829d9ea362ceb1 (diff)
downloadwebrtc-ba41365cf8e326bff31b693ddef75ba1c38c23a0.tar.gz
Reformatted rw_lock classes.
BUG= TEST=Trybots. Review URL: https://webrtc-codereview.appspot.com/1007004 git-svn-id: http://webrtc.googlecode.com/svn/trunk/webrtc@3305 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'system_wrappers')
-rw-r--r--system_wrappers/interface/rw_lock_wrapper.h75
-rw-r--r--system_wrappers/source/rw_lock.cc8
-rw-r--r--system_wrappers/source/rw_lock_generic.cc6
-rw-r--r--system_wrappers/source/rw_lock_generic.h32
-rw-r--r--system_wrappers/source/rw_lock_posix.cc16
-rw-r--r--system_wrappers/source/rw_lock_posix.h27
-rw-r--r--system_wrappers/source/rw_lock_win.cc28
-rw-r--r--system_wrappers/source/rw_lock_win.h8
8 files changed, 96 insertions, 104 deletions
diff --git a/system_wrappers/interface/rw_lock_wrapper.h b/system_wrappers/interface/rw_lock_wrapper.h
index 57282027..91305c15 100644
--- a/system_wrappers/interface/rw_lock_wrapper.h
+++ b/system_wrappers/interface/rw_lock_wrapper.h
@@ -11,65 +11,58 @@
#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_RW_LOCK_WRAPPER_H_
#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_RW_LOCK_WRAPPER_H_
-// Note, Windows pre-Vista version of RW locks are not supported nativly. For
+// Note, Windows pre-Vista version of RW locks are not supported natively. For
// these OSs regular critical sections have been used to approximate RW lock
// functionality and will therefore have worse performance.
namespace webrtc {
-class RWLockWrapper
-{
-public:
- static RWLockWrapper* CreateRWLock();
- virtual ~RWLockWrapper() {}
+class RWLockWrapper {
+ public:
+ static RWLockWrapper* CreateRWLock();
+ virtual ~RWLockWrapper() {}
- virtual void AcquireLockExclusive() = 0;
- virtual void ReleaseLockExclusive() = 0;
+ virtual void AcquireLockExclusive() = 0;
+ virtual void ReleaseLockExclusive() = 0;
- virtual void AcquireLockShared() = 0;
- virtual void ReleaseLockShared() = 0;
+ virtual void AcquireLockShared() = 0;
+ virtual void ReleaseLockShared() = 0;
};
// RAII extensions of the RW lock. Prevents Acquire/Release missmatches and
// provides more compact locking syntax.
-class ReadLockScoped
-{
-public:
- ReadLockScoped(RWLockWrapper& rwLock)
- :
- _rwLock(rwLock)
- {
- _rwLock.AcquireLockShared();
- }
+class ReadLockScoped {
+ public:
+ ReadLockScoped(RWLockWrapper& rw_lock)
+ :
+ rw_lock_(rw_lock) {
+ rw_lock_.AcquireLockShared();
+ }
- ~ReadLockScoped()
- {
- _rwLock.ReleaseLockShared();
- }
+ ~ReadLockScoped() {
+ rw_lock_.ReleaseLockShared();
+ }
-private:
- RWLockWrapper& _rwLock;
+ private:
+ RWLockWrapper& rw_lock_;
};
-class WriteLockScoped
-{
-public:
- WriteLockScoped(RWLockWrapper& rwLock)
- :
- _rwLock(rwLock)
- {
- _rwLock.AcquireLockExclusive();
- }
+class WriteLockScoped {
+ public:
+ WriteLockScoped(RWLockWrapper& rw_lock)
+ :
+ rw_lock_(rw_lock) {
+ rw_lock_.AcquireLockExclusive();
+ }
- ~WriteLockScoped()
- {
- _rwLock.ReleaseLockExclusive();
- }
+ ~WriteLockScoped() {
+ rw_lock_.ReleaseLockExclusive();
+ }
-private:
- RWLockWrapper& _rwLock;
+ private:
+ RWLockWrapper& rw_lock_;
};
} // namespace webrtc
-#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_RW_LOCK_WRAPPER_H_
+#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_RW_LOCK_WRAPPER_H_
diff --git a/system_wrappers/source/rw_lock.cc b/system_wrappers/source/rw_lock.cc
index d3134684..8b76eb86 100644
--- a/system_wrappers/source/rw_lock.cc
+++ b/system_wrappers/source/rw_lock.cc
@@ -8,15 +8,15 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include "rw_lock_wrapper.h"
+#include "webrtc/system_wrappers/interface/rw_lock_wrapper.h"
#include <assert.h>
#if defined(_WIN32)
-#include "rw_lock_generic.h"
-#include "rw_lock_win.h"
+#include "webrtc/system_wrappers/source/rw_lock_generic.h"
+#include "webrtc/system_wrappers/source/rw_lock_win.h"
#else
-#include "rw_lock_posix.h"
+#include "webrtc/system_wrappers/source/rw_lock_posix.h"
#endif
namespace webrtc {
diff --git a/system_wrappers/source/rw_lock_generic.cc b/system_wrappers/source/rw_lock_generic.cc
index 21e9a375..0ca95187 100644
--- a/system_wrappers/source/rw_lock_generic.cc
+++ b/system_wrappers/source/rw_lock_generic.cc
@@ -8,10 +8,10 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include "system_wrappers/source/rw_lock_generic.h"
+#include "webrtc/system_wrappers/source/rw_lock_generic.h"
-#include "system_wrappers/interface/condition_variable_wrapper.h"
-#include "system_wrappers/interface/critical_section_wrapper.h"
+#include "webrtc/system_wrappers/interface/condition_variable_wrapper.h"
+#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
namespace webrtc {
diff --git a/system_wrappers/source/rw_lock_generic.h b/system_wrappers/source/rw_lock_generic.h
index d81b8f0f..cd5848f4 100644
--- a/system_wrappers/source/rw_lock_generic.h
+++ b/system_wrappers/source/rw_lock_generic.h
@@ -11,7 +11,7 @@
#ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_RW_LOCK_GENERIC_H_
#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_RW_LOCK_GENERIC_H_
-#include "system_wrappers/interface/rw_lock_wrapper.h"
+#include "webrtc/system_wrappers/interface/rw_lock_wrapper.h"
namespace webrtc {
@@ -19,25 +19,25 @@ class CriticalSectionWrapper;
class ConditionVariableWrapper;
class RWLockGeneric : public RWLockWrapper {
-public:
- RWLockGeneric();
- virtual ~RWLockGeneric();
+ public:
+ RWLockGeneric();
+ virtual ~RWLockGeneric();
- virtual void AcquireLockExclusive();
- virtual void ReleaseLockExclusive();
+ virtual void AcquireLockExclusive();
+ virtual void ReleaseLockExclusive();
- virtual void AcquireLockShared();
- virtual void ReleaseLockShared();
+ virtual void AcquireLockShared();
+ virtual void ReleaseLockShared();
-private:
- CriticalSectionWrapper* critical_section_;
- ConditionVariableWrapper* read_condition_;
- ConditionVariableWrapper* write_condition_;
+ private:
+ CriticalSectionWrapper* critical_section_;
+ ConditionVariableWrapper* read_condition_;
+ ConditionVariableWrapper* write_condition_;
- int readers_active_;
- bool writer_active_;
- int readers_waiting_;
- int writers_waiting_;
+ int readers_active_;
+ bool writer_active_;
+ int readers_waiting_;
+ int writers_waiting_;
};
} // namespace webrtc
diff --git a/system_wrappers/source/rw_lock_posix.cc b/system_wrappers/source/rw_lock_posix.cc
index f21e0b04..cdcb7fb5 100644
--- a/system_wrappers/source/rw_lock_posix.cc
+++ b/system_wrappers/source/rw_lock_posix.cc
@@ -8,15 +8,15 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include "system_wrappers/source/rw_lock_posix.h"
+#include "webrtc/system_wrappers/source/rw_lock_posix.h"
namespace webrtc {
-RWLockPosix::RWLockPosix() : _lock() {
+RWLockPosix::RWLockPosix() : lock_() {
}
RWLockPosix::~RWLockPosix() {
- pthread_rwlock_destroy(&_lock);
+ pthread_rwlock_destroy(&lock_);
}
RWLockPosix* RWLockPosix::Create() {
@@ -29,23 +29,23 @@ RWLockPosix* RWLockPosix::Create() {
}
bool RWLockPosix::Init() {
- return pthread_rwlock_init(&_lock, 0) == 0;
+ return pthread_rwlock_init(&lock_, 0) == 0;
}
void RWLockPosix::AcquireLockExclusive() {
- pthread_rwlock_wrlock(&_lock);
+ pthread_rwlock_wrlock(&lock_);
}
void RWLockPosix::ReleaseLockExclusive() {
- pthread_rwlock_unlock(&_lock);
+ pthread_rwlock_unlock(&lock_);
}
void RWLockPosix::AcquireLockShared() {
- pthread_rwlock_rdlock(&_lock);
+ pthread_rwlock_rdlock(&lock_);
}
void RWLockPosix::ReleaseLockShared() {
- pthread_rwlock_unlock(&_lock);
+ pthread_rwlock_unlock(&lock_);
}
} // namespace webrtc
diff --git a/system_wrappers/source/rw_lock_posix.h b/system_wrappers/source/rw_lock_posix.h
index 930e7cc1..a56ae12d 100644
--- a/system_wrappers/source/rw_lock_posix.h
+++ b/system_wrappers/source/rw_lock_posix.h
@@ -11,29 +11,28 @@
#ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_RW_LOCK_POSIX_H_
#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_RW_LOCK_POSIX_H_
-#include "system_wrappers/interface/rw_lock_wrapper.h"
+#include "webrtc/system_wrappers/interface/rw_lock_wrapper.h"
#include <pthread.h>
namespace webrtc {
-class RWLockPosix : public RWLockWrapper
-{
-public:
- static RWLockPosix* Create();
- virtual ~RWLockPosix();
+class RWLockPosix : public RWLockWrapper {
+ public:
+ static RWLockPosix* Create();
+ virtual ~RWLockPosix();
- virtual void AcquireLockExclusive();
- virtual void ReleaseLockExclusive();
+ virtual void AcquireLockExclusive();
+ virtual void ReleaseLockExclusive();
- virtual void AcquireLockShared();
- virtual void ReleaseLockShared();
+ virtual void AcquireLockShared();
+ virtual void ReleaseLockShared();
-private:
- RWLockPosix();
- bool Init();
+ private:
+ RWLockPosix();
+ bool Init();
- pthread_rwlock_t _lock;
+ pthread_rwlock_t lock_;
};
} // namespace webrtc
diff --git a/system_wrappers/source/rw_lock_win.cc b/system_wrappers/source/rw_lock_win.cc
index f0333b82..aea74fa4 100644
--- a/system_wrappers/source/rw_lock_win.cc
+++ b/system_wrappers/source/rw_lock_win.cc
@@ -8,9 +8,9 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include "system_wrappers/source/rw_lock_win.h"
+#include "webrtc/system_wrappers/source/rw_lock_win.h"
-#include "trace.h"
+#include "webrtc/system_wrappers/interface/trace.h"
namespace webrtc {
@@ -18,13 +18,13 @@ static bool native_rw_locks_supported = false;
static bool module_load_attempted = false;
static HMODULE library = NULL;
-typedef void (WINAPI *InitializeSRWLock)(PSRWLOCK);
+typedef void (WINAPI* InitializeSRWLock)(PSRWLOCK);
-typedef void (WINAPI *AcquireSRWLockExclusive)(PSRWLOCK);
-typedef void (WINAPI *ReleaseSRWLockExclusive)(PSRWLOCK);
+typedef void (WINAPI* AcquireSRWLockExclusive)(PSRWLOCK);
+typedef void (WINAPI* ReleaseSRWLockExclusive)(PSRWLOCK);
-typedef void (WINAPI *AcquireSRWLockShared)(PSRWLOCK);
-typedef void (WINAPI *ReleaseSRWLockShared)(PSRWLOCK);
+typedef void (WINAPI* AcquireSRWLockShared)(PSRWLOCK);
+typedef void (WINAPI* ReleaseSRWLockShared)(PSRWLOCK);
InitializeSRWLock initialize_srw_lock;
AcquireSRWLockExclusive acquire_srw_lock_exclusive;
@@ -72,18 +72,18 @@ bool RWLockWin::LoadModule() {
WEBRTC_TRACE(kTraceStateInfo, kTraceUtility, -1, "Loaded Kernel.dll");
initialize_srw_lock =
- (InitializeSRWLock)GetProcAddress(library, "InitializeSRWLock");
+ (InitializeSRWLock)GetProcAddress(library, "InitializeSRWLock");
acquire_srw_lock_exclusive =
- (AcquireSRWLockExclusive)GetProcAddress(library,
- "AcquireSRWLockExclusive");
+ (AcquireSRWLockExclusive)GetProcAddress(library,
+ "AcquireSRWLockExclusive");
release_srw_lock_exclusive =
- (ReleaseSRWLockExclusive)GetProcAddress(library,
- "ReleaseSRWLockExclusive");
+ (ReleaseSRWLockExclusive)GetProcAddress(library,
+ "ReleaseSRWLockExclusive");
acquire_srw_lock_shared =
- (AcquireSRWLockShared)GetProcAddress(library, "AcquireSRWLockShared");
+ (AcquireSRWLockShared)GetProcAddress(library, "AcquireSRWLockShared");
release_srw_lock_shared =
- (ReleaseSRWLockShared)GetProcAddress(library, "ReleaseSRWLockShared");
+ (ReleaseSRWLockShared)GetProcAddress(library, "ReleaseSRWLockShared");
if (initialize_srw_lock && acquire_srw_lock_exclusive &&
release_srw_lock_exclusive && acquire_srw_lock_shared &&
diff --git a/system_wrappers/source/rw_lock_win.h b/system_wrappers/source/rw_lock_win.h
index bc052e41..6f7cd334 100644
--- a/system_wrappers/source/rw_lock_win.h
+++ b/system_wrappers/source/rw_lock_win.h
@@ -8,10 +8,10 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_RW_LOCK_WIN__H_
-#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_RW_LOCK_WIN__H_
+#ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_RW_LOCK_WIN_H_
+#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_RW_LOCK_WIN_H_
-#include "system_wrappers/interface/rw_lock_wrapper.h"
+#include "webrtc/system_wrappers/interface/rw_lock_wrapper.h"
#include <Windows.h>
@@ -37,4 +37,4 @@ class RWLockWin : public RWLockWrapper {
} // namespace webrtc
-#endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_RW_LOCK_WIN__H_
+#endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_RW_LOCK_WIN_H_