mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-15 15:41:24 +01:00
make overly verbose logging conditional
This commit is contained in:
parent
c67c8054b0
commit
051108e14e
1 changed files with 24 additions and 0 deletions
|
@ -30,12 +30,18 @@ class MutexLock {
|
||||||
public:
|
public:
|
||||||
MutexLock( pthread_mutex_t* mutex ) {
|
MutexLock( pthread_mutex_t* mutex ) {
|
||||||
m_mutex = mutex;
|
m_mutex = mutex;
|
||||||
|
#ifdef DEBUG_LOCKS
|
||||||
logf( "locking mutex %x", mutex );
|
logf( "locking mutex %x", mutex );
|
||||||
|
#endif
|
||||||
pthread_mutex_lock( mutex );
|
pthread_mutex_lock( mutex );
|
||||||
|
#ifdef DEBUG_LOCKS
|
||||||
logf( "successfully locked mutex %x", mutex );
|
logf( "successfully locked mutex %x", mutex );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
~MutexLock() {
|
~MutexLock() {
|
||||||
|
#ifdef DEBUG_LOCKS
|
||||||
logf( "UNlocking mutex %x", m_mutex );
|
logf( "UNlocking mutex %x", m_mutex );
|
||||||
|
#endif
|
||||||
pthread_mutex_unlock( m_mutex );
|
pthread_mutex_unlock( m_mutex );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,12 +54,18 @@ class SocketWriteLock {
|
||||||
SocketWriteLock( int socket ) {
|
SocketWriteLock( int socket ) {
|
||||||
m_socket = socket;
|
m_socket = socket;
|
||||||
m_mutex = SocketMgr::GetWriteMutexForSocket( socket );
|
m_mutex = SocketMgr::GetWriteMutexForSocket( socket );
|
||||||
|
#ifdef DEBUG_LOCKS
|
||||||
logf( "locking mutex %x for socket %d", m_mutex, socket );
|
logf( "locking mutex %x for socket %d", m_mutex, socket );
|
||||||
|
#endif
|
||||||
pthread_mutex_lock( m_mutex );
|
pthread_mutex_lock( m_mutex );
|
||||||
|
#ifdef DEBUG_LOCKS
|
||||||
logf( "successfully locked mutex %x for socket %d", m_mutex, socket );
|
logf( "successfully locked mutex %x for socket %d", m_mutex, socket );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
~SocketWriteLock() {
|
~SocketWriteLock() {
|
||||||
|
#ifdef DEBUG_LOCKS
|
||||||
logf( "UNlocking mutex %x for socket %d", m_mutex, m_socket );
|
logf( "UNlocking mutex %x for socket %d", m_mutex, m_socket );
|
||||||
|
#endif
|
||||||
pthread_mutex_unlock( m_mutex );
|
pthread_mutex_unlock( m_mutex );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,14 +77,20 @@ class SocketWriteLock {
|
||||||
class RWReadLock {
|
class RWReadLock {
|
||||||
public:
|
public:
|
||||||
RWReadLock( pthread_rwlock_t* rwl ) {
|
RWReadLock( pthread_rwlock_t* rwl ) {
|
||||||
|
#ifdef DEBUG_LOCKS
|
||||||
logf( "locking rwlock %p for read", rwl );
|
logf( "locking rwlock %p for read", rwl );
|
||||||
|
#endif
|
||||||
pthread_rwlock_rdlock( rwl );
|
pthread_rwlock_rdlock( rwl );
|
||||||
|
#ifdef DEBUG_LOCKS
|
||||||
logf( "locked rwlock %p for read", rwl );
|
logf( "locked rwlock %p for read", rwl );
|
||||||
|
#endif
|
||||||
_rwl = rwl;
|
_rwl = rwl;
|
||||||
}
|
}
|
||||||
~RWReadLock() {
|
~RWReadLock() {
|
||||||
pthread_rwlock_unlock( _rwl );
|
pthread_rwlock_unlock( _rwl );
|
||||||
|
#ifdef DEBUG_LOCKS
|
||||||
logf( "unlocked rwlock %p", _rwl );
|
logf( "unlocked rwlock %p", _rwl );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -82,13 +100,19 @@ class RWReadLock {
|
||||||
class RWWriteLock {
|
class RWWriteLock {
|
||||||
public:
|
public:
|
||||||
RWWriteLock( pthread_rwlock_t* rwl ) : _rwl(rwl) {
|
RWWriteLock( pthread_rwlock_t* rwl ) : _rwl(rwl) {
|
||||||
|
#ifdef DEBUG_LOCKS
|
||||||
logf( "locking rwlock %p for write", rwl );
|
logf( "locking rwlock %p for write", rwl );
|
||||||
|
#endif
|
||||||
pthread_rwlock_wrlock( rwl );
|
pthread_rwlock_wrlock( rwl );
|
||||||
|
#ifdef DEBUG_LOCKS
|
||||||
logf( "locked rwlock %p for write", rwl );
|
logf( "locked rwlock %p for write", rwl );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
~RWWriteLock() {
|
~RWWriteLock() {
|
||||||
pthread_rwlock_unlock( _rwl );
|
pthread_rwlock_unlock( _rwl );
|
||||||
|
#ifdef DEBUG_LOCKS
|
||||||
logf( "unlocked rwlock %p", _rwl );
|
logf( "unlocked rwlock %p", _rwl );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
pthread_rwlock_t* _rwl;
|
pthread_rwlock_t* _rwl;
|
||||||
|
|
Loading…
Reference in a new issue