Any way of pumping more events inside of MessageReceived()?

I’m porting a cross-platform GUI thingus to Haiku, and need a way of getting/dispatching more events before MessageReceived() has returned. Reentrant message handling, you might call it. (This is to give the illusion of a blocking API call, when behind the scenes events are still being processed)

Is this possible from within a BLooper as it stands, or do I need to come up with my own solution? I don’t think it would be too difficult, but I wanted to check with the experts before I overly complicate this.

edit: I should add that I’ve already tried experimenting with the looper’s message queue, but it seems to be stuck. Hence my asking here whether it’s possible in the first place.

For anybody who comes across this in the future, I ended up implementing this with a BMessageQueue on a clean (non-BLooper) thread.

1 Like

Another way would be to hold onto the BMessage with the work request (take it out of normal processing with DetachCurrentMessage), do your other stuff, and when the work is done, activate the reply to the saved message.

See BLooper’s DetachCurrentMessage(), BMessage’s SendReply(). There’s an example of this method in ScriptOCron.cpp available at http://web.ncf.ca/au829/BeOS/AGMSScriptOCron-2.91.zip

Docs:
https://www.haiku-os.org/docs/api/classBLooper.html#a7c8f05bcc354bc1d53026417417120e3
https://www.haiku-os.org/docs/api/classBMessage.html#aad1eb085346e2c91133e372e7924637c

You need to use a BMessageFilter. Hope that helps.