* Added a Dano extension to BMessageQueue: IsNextMessage().
* BLooper::AddMessage() is now using this method to determine wether or not to update its looper thread. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19956 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2005, Haiku, Inc. All Rights Reserved.
|
* Copyright 2001-2007, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef _MESSAGE_QUEUE_H
|
#ifndef _MESSAGE_QUEUE_H
|
||||||
@@ -30,6 +30,7 @@ class BMessageQueue {
|
|||||||
bool IsLocked() const;
|
bool IsLocked() const;
|
||||||
|
|
||||||
BMessage *NextMessage();
|
BMessage *NextMessage();
|
||||||
|
bool IsNextMessage(const BMessage* message) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Reserved space in the vtable for future changes to BMessageQueue
|
// Reserved space in the vtable for future changes to BMessageQueue
|
||||||
|
|||||||
+10
-5
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2005, Haiku.
|
* Copyright 2001-2007, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
* Axel Dörfler, [email protected]
|
* Axel Dörfler, [email protected]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** BLooper class spawns a thread that runs a message loop. */
|
/*! BLooper class spawns a thread that runs a message loop. */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@note Although I'm implementing "by the book" for now, I would like to
|
@note Although I'm implementing "by the book" for now, I would like to
|
||||||
@@ -1076,11 +1076,16 @@ BLooper::InitData(const char *name, int32 priority, int32 portCapacity)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BLooper::AddMessage(BMessage* msg)
|
BLooper::AddMessage(BMessage* message)
|
||||||
{
|
{
|
||||||
_AddMessagePriv(msg);
|
_AddMessagePriv(message);
|
||||||
|
|
||||||
// ToDo: if called from a different thread, we need to wake up the looper
|
// wakeup looper when being called from other threads if necessary
|
||||||
|
if (find_thread(NULL) != Thread()
|
||||||
|
&& fQueue->IsNextMessage(message) && port_count(fMsgPort) <= 0) {
|
||||||
|
// there is currently no message waiting, and we need to wakeup the looper
|
||||||
|
write_port_etc(fMsgPort, 0, NULL, 0, B_RELATIVE_TIMEOUT, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2005, Haiku, Inc. All Rights Reserved.
|
* Copyright 2001-2007, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -262,6 +262,18 @@ BMessageQueue::NextMessage()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Checks wether or not the specified \a message is the message
|
||||||
|
you would get when calling NextMessage().
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
BMessageQueue::IsNextMessage(const BMessage* message) const
|
||||||
|
{
|
||||||
|
BAutolock _(fLock);
|
||||||
|
return fHead == message;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief This method is only here for R5 binary compatibility!
|
\brief This method is only here for R5 binary compatibility!
|
||||||
It should be dropped as soon as possible (it misses the const qualifier).
|
It should be dropped as soon as possible (it misses the const qualifier).
|
||||||
|
|||||||
Reference in New Issue
Block a user