[haiku-3rdparty-dev] Re: Dispatch messages

  • From: Rene Gollent <anevilyak@xxxxxxxxx>
  • To: haiku-3rdparty-dev@xxxxxxxxxxxxx
  • Date: Tue, 22 Nov 2022 13:37:50 -0500

On Tue, Nov 22, 2022 at 12:51 PM Carlo Lanzotti <clanzotti@xxxxxxxxxxxxx>
wrote:


It is still not clear to me how a BMessageQueue grab messages from the
current thread (and it’s BLooper) and store it without forwarding to the
main window, but I’ve no time to to check the code. Maybe some of you can
give me explanations? Just to be sure that this is a valid way to handle
this (Note that I do not call Application::Run()).


The long and short of it is that underlying a BLooper is a message port (
https://www.haiku-os.org/legacy-docs/bebook/TheKernelKit_Ports_Overview.html
) and BMessageQueue (
https://www.haiku-os.org/docs/api/classBMessageQueue.html ;) ; when running,
the looper normally sits waiting for available data on the port (these can
be sent by anyone that has access to the port ID, e.g. app/input_server,
other apps via BMessenger, etc.). The raw bytes on the port are then
unflattened into BMessage objects, and added to the looper's message queue
to be processed in FIFO order. Note that each window/looper has its own
message queue, and locked access is important since each window gets its
own thread.

Regards,

Rene

Other related posts: