The ServerWindow now keeps the desktop (read) lock for up to 70 messages at once.
This should make drawing a bit smoother. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15515 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -2168,39 +2168,69 @@ ServerWindow::_MessageLooper()
|
|||||||
printf("ServerWindow %s: lock acquisition took %Ld usecs\n", Title(), diff);
|
printf("ServerWindow %s: lock acquisition took %Ld usecs\n", Title(), diff);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (code == AS_DELETE_WINDOW || code == kMsgQuitLooper) {
|
int32 messagesProcessed = 0;
|
||||||
// this means the client has been killed
|
bool lockedDesktop = false;
|
||||||
STRACE(("ServerWindow %s received 'AS_DELETE_WINDOW' message code\n",
|
|
||||||
Title()));
|
|
||||||
|
|
||||||
quitLoop = true;
|
while (true) {
|
||||||
|
if (code == AS_DELETE_WINDOW || code == kMsgQuitLooper) {
|
||||||
|
// this means the client has been killed
|
||||||
|
STRACE(("ServerWindow %s received 'AS_DELETE_WINDOW' message code\n",
|
||||||
|
Title()));
|
||||||
|
|
||||||
// ServerWindow's destructor takes care of pulling this object off the desktop.
|
if (lockedDesktop)
|
||||||
if (!fWindowLayer->IsHidden())
|
fDesktop->UnlockSingleWindow();
|
||||||
CRITICAL("ServerWindow: a window must be hidden before it's deleted\n");
|
|
||||||
} else {
|
quitLoop = true;
|
||||||
fDesktop->LockSingleWindow();
|
|
||||||
|
// ServerWindow's destructor takes care of pulling this object off the desktop.
|
||||||
|
if (!fWindowLayer->IsHidden())
|
||||||
|
CRITICAL("ServerWindow: a window must be hidden before it's deleted\n");
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!lockedDesktop) {
|
||||||
|
// only lock it once
|
||||||
|
fDesktop->LockSingleWindow();
|
||||||
|
lockedDesktop = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (atomic_and(&fRedrawRequested, 0) != 0)
|
if (atomic_and(&fRedrawRequested, 0) != 0)
|
||||||
fWindowLayer->RedrawDirtyRegion();
|
fWindowLayer->RedrawDirtyRegion();
|
||||||
|
|
||||||
_DispatchMessage(code, receiver);
|
_DispatchMessage(code, receiver);
|
||||||
fDesktop->UnlockSingleWindow();
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef PROFILE_MESSAGE_LOOP
|
#ifdef PROFILE_MESSAGE_LOOP
|
||||||
if (code >= 0 && code < AS_LAST_CODE) {
|
if (code >= 0 && code < AS_LAST_CODE) {
|
||||||
diff = system_time() - start;
|
diff = system_time() - start;
|
||||||
atomic_add(&sMessageProfile[code].count, 1);
|
atomic_add(&sMessageProfile[code].count, 1);
|
||||||
#ifdef __HAIKU__
|
#ifdef __HAIKU__
|
||||||
atomic_add64(&sMessageProfile[code].time, diff);
|
atomic_add64(&sMessageProfile[code].time, diff);
|
||||||
#else
|
#else
|
||||||
sMessageProfile[code].time += diff;
|
sMessageProfile[code].time += diff;
|
||||||
#endif
|
#endif
|
||||||
if (diff > 10000)
|
if (diff > 10000)
|
||||||
printf("ServerWindow %s: message %ld took %Ld usecs\n", Title(), code, diff);
|
printf("ServerWindow %s: message %ld took %Ld usecs\n", Title(), code, diff);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// only process up to 70 waiting messages at once (we have the Desktop locked)
|
||||||
|
if (!receiver.HasMessages() || ++messagesProcessed > 70) {
|
||||||
|
fDesktop->UnlockSingleWindow();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
status_t status = receiver.GetNextMessage(code);
|
||||||
|
if (status < B_OK) {
|
||||||
|
// that shouldn't happen, it's our port
|
||||||
|
printf("Someone deleted our message port!\n");
|
||||||
|
fDesktop->UnlockSingleWindow();
|
||||||
|
|
||||||
|
// try to let our client die happily
|
||||||
|
NotifyQuitRequested();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
Unlock();
|
Unlock();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user