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

  • From: Carlo Lanzotti <clanzotti@xxxxxxxxxxxxx>
  • To: haiku-3rdparty-dev@xxxxxxxxxxxxx
  • Date: Tue, 22 Nov 2022 20:26:40 +0100

Hi Rene,

Thanks, now I understand. I did read about ports but I was not sure how it 
relate to BLooper and BMessageQueue.

Regards,

Carlo

Il giorno 22 nov 2022, alle ore 19:39, Rene Gollent <anevilyak@xxxxxxxxx> ha 
scritto:





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: