in case DEBUG is defined, BLooper don't use the benaphore style lock. Useful for debugging
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17045 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
835a7ebdf0
commit
791b9c2141
@ -551,15 +551,16 @@ PRINT((" fOwnerCount now: %ld\n", fOwnerCount));
|
|||||||
// Set fOwner to invalid thread_id (< 0)
|
// Set fOwner to invalid thread_id (< 0)
|
||||||
fOwner = -1;
|
fOwner = -1;
|
||||||
|
|
||||||
|
#if DEBUG < 1
|
||||||
// Decrement requested lock count (using fAtomicCount for this)
|
// Decrement requested lock count (using fAtomicCount for this)
|
||||||
int32 atomicCount = atomic_add(&fAtomicCount, -1);
|
int32 atomicCount = atomic_add(&fAtomicCount, -1);
|
||||||
PRINT((" fAtomicCount now: %ld\n", fAtomicCount));
|
PRINT((" fAtomicCount now: %ld\n", fAtomicCount));
|
||||||
|
|
||||||
// Check if anyone is waiting for a lock
|
// Check if anyone is waiting for a lock
|
||||||
if (atomicCount > 1) {
|
// and release if it's the case
|
||||||
// release the lock
|
if (atomicCount > 1)
|
||||||
release_sem(fLockSem);
|
#endif
|
||||||
}
|
release_sem(fLockSem);
|
||||||
}
|
}
|
||||||
PRINT(("BLooper::Unlock() done\n"));
|
PRINT(("BLooper::Unlock() done\n"));
|
||||||
}
|
}
|
||||||
@ -1004,13 +1005,16 @@ status_t
|
|||||||
BLooper::_LockComplete(BLooper *looper, int32 oldCount, thread_id thread, sem_id sem, bigtime_t timeout)
|
BLooper::_LockComplete(BLooper *looper, int32 oldCount, thread_id thread, sem_id sem, bigtime_t timeout)
|
||||||
{
|
{
|
||||||
status_t err = B_OK;
|
status_t err = B_OK;
|
||||||
|
|
||||||
|
#if DEBUG < 1
|
||||||
if (oldCount > 0) {
|
if (oldCount > 0) {
|
||||||
|
#endif
|
||||||
do {
|
do {
|
||||||
err = acquire_sem_etc(sem, 1, B_RELATIVE_TIMEOUT, timeout);
|
err = acquire_sem_etc(sem, 1, B_RELATIVE_TIMEOUT, timeout);
|
||||||
} while (err == B_INTERRUPTED);
|
} while (err == B_INTERRUPTED);
|
||||||
|
#if DEBUG < 1
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (err == B_OK) {
|
if (err == B_OK) {
|
||||||
// Assign current thread to fOwner
|
// Assign current thread to fOwner
|
||||||
looper->fOwner = thread;
|
looper->fOwner = thread;
|
||||||
@ -1052,7 +1056,11 @@ BLooper::InitData(const char *name, int32 priority, int32 portCapacity)
|
|||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
name = "anonymous looper";
|
name = "anonymous looper";
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
fLockSem = create_sem(1, name);
|
||||||
|
#else
|
||||||
fLockSem = create_sem(0, name);
|
fLockSem = create_sem(0, name);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (portCapacity <= 0)
|
if (portCapacity <= 0)
|
||||||
portCapacity = B_LOOPER_PORT_DEFAULT_CAPACITY;
|
portCapacity = B_LOOPER_PORT_DEFAULT_CAPACITY;
|
||||||
@ -1493,9 +1501,11 @@ BLooper::UnlockFully()
|
|||||||
fOwnerCount = 0;
|
fOwnerCount = 0;
|
||||||
// Nobody owns the lock now
|
// Nobody owns the lock now
|
||||||
fOwner = -1;
|
fOwner = -1;
|
||||||
|
#if DEBUG < 1
|
||||||
// There is now one less thread holding a lock on this looper
|
// There is now one less thread holding a lock on this looper
|
||||||
int32 atomicCount = atomic_add(&fAtomicCount, -1);
|
int32 atomicCount = atomic_add(&fAtomicCount, -1);
|
||||||
if (atomicCount > 1)
|
if (atomicCount > 1)
|
||||||
|
#endif
|
||||||
release_sem(fLockSem);
|
release_sem(fLockSem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user