Implemented direct message passing for local targets; this fixes a deadlock
with PostMessage() in case the message queue is full. Some notes: * for synchronous replies, we don't use this mechanism yet, but it could be extended to do that as well. * the code looks so complicated because we need a way to access the looper's queue without locking it (to prevent deadlocks); like Dano's solution, I've abused BTokenSpace to store a BDirectMessageTarget with a BHandler. * we also need to decouple the lifetime of a looper's queue from its target, as we cannot lock the looper, and therefore, can't guarantee it stays valid as long as we're accessing it outside of BLooper. * init_clipboard() now needs to be done after the global constructors have been called - since sending messages now needs gDefaultTokens to be initialized. Since this is done per image, it shouldn't cause any troubles, though. * some minor cleanup, removed unused _msg_cache_cleanup_() and friends. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19968 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#include <input_globals.h>
|
||||
#include <AppMisc.h>
|
||||
#include <ApplicationPrivate.h>
|
||||
#include <DirectMessageTarget.h>
|
||||
#include <InputServerTypes.h>
|
||||
#include <MenuPrivate.h>
|
||||
#include <MessagePrivate.h>
|
||||
@@ -2488,7 +2489,7 @@ BWindow::_DequeueAll()
|
||||
for (int32 i = 0; i < count; i++) {
|
||||
BMessage *message = MessageFromPort(0);
|
||||
if (message != NULL)
|
||||
fQueue->AddMessage(message);
|
||||
fDirectTarget->Queue()->AddMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2536,8 +2537,8 @@ BWindow::task_looper()
|
||||
|
||||
bool dispatchNextMessage = true;
|
||||
while (!fTerminating && dispatchNextMessage) {
|
||||
// Get next message from queue (assign to fLastMessage)
|
||||
fLastMessage = fQueue->NextMessage();
|
||||
// Get next message from queue (assign to fLastMessage)
|
||||
fLastMessage = fDirectTarget->Queue()->NextMessage();
|
||||
|
||||
// Lock the looper
|
||||
if (!Lock())
|
||||
|
||||
Reference in New Issue
Block a user