Now uses the cache stack trick for a cheaper check_lock() version as suggested by stippi.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21863 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -159,13 +159,14 @@ private:
|
|||||||
int32 fOwnerCount;
|
int32 fOwnerCount;
|
||||||
thread_id fOwner;
|
thread_id fOwner;
|
||||||
thread_id fThread;
|
thread_id fThread;
|
||||||
|
addr_t fCachedStack;
|
||||||
int32 fInitPriority;
|
int32 fInitPriority;
|
||||||
BHandler* fPreferred;
|
BHandler* fPreferred;
|
||||||
BList fHandlers;
|
BList fHandlers;
|
||||||
BList* fCommonFilters;
|
BList* fCommonFilters;
|
||||||
bool fTerminating;
|
bool fTerminating;
|
||||||
bool fRunCalled;
|
bool fRunCalled;
|
||||||
uint32 _reserved[12];
|
uint32 _reserved[11];
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _LOOPER_H
|
#endif // _LOOPER_H
|
||||||
|
|||||||
@@ -546,7 +546,6 @@ BLooper::IsLocked() const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Got this from Jeremy's BLocker implementation
|
|
||||||
return find_thread(NULL) == fOwner;
|
return find_thread(NULL) == fOwner;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -907,7 +906,8 @@ BLooper::_Lock(BLooper* looper, port_id port, bigtime_t timeout)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
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;
|
||||||
|
|
||||||
@@ -922,6 +922,7 @@ BLooper::_LockComplete(BLooper *looper, int32 oldCount, thread_id thread, sem_id
|
|||||||
#endif
|
#endif
|
||||||
if (err == B_OK) {
|
if (err == B_OK) {
|
||||||
looper->fOwner = thread;
|
looper->fOwner = thread;
|
||||||
|
looper->fCachedStack = (addr_t)&err & ~(B_PAGE_SIZE - 1);
|
||||||
looper->fOwnerCount = 1;
|
looper->fOwnerCount = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1332,8 +1333,12 @@ BLooper::check_lock()
|
|||||||
// This is a cheap variant of AssertLocked()
|
// This is a cheap variant of AssertLocked()
|
||||||
// It is used in situations where it's clear that the looper is valid,
|
// It is used in situations where it's clear that the looper is valid,
|
||||||
// ie. from handlers
|
// ie. from handlers
|
||||||
if (fOwner == -1 || fOwner != find_thread(NULL))
|
uint32 stack;
|
||||||
debugger("Looper must be locked.");
|
if (((uint32)&stack & ~(B_PAGE_SIZE - 1)) == fCachedStack
|
||||||
|
|| fOwner == find_thread(NULL))
|
||||||
|
return;
|
||||||
|
|
||||||
|
debugger("Looper must be locked.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user