[haiku-development] Re: Additional Functionality to BMessenger

  • From: "Adrien Destugues" <pulkomandy@xxxxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Fri, 31 May 2019 06:42:53 +0000

30 mai 2019 14:02 "Rene Gollent" <anevilyak@xxxxxxxxx> a écrit:

On Thu, May 30, 2019 at 7:54 AM Hamish Morrison <hamishm53@xxxxxxxxx> wrote:

Ah I see. It would be nice if a BLooper could listen to and dispatch
multiple sources of events though - i.e. not only BMessages from a
port, but also readiness notifications on sockets. Other platforms'
runloops provide this and it's quite a clean model, since you can keep
everything on one thread.

wait_for_objects() (c.f. OS.h) can technically do that, but not within
the looper model; ergo, you'd have to manually handle subsequently
retrieving the message from the port and forward it on to an actual
looper for message processing, if you wanted to go that route.

Actually, it's possible to hack this into a BLooper, by blocking on
wait_for_objects at the end of the MessageReceived function on
wait_for_objects, and exiting it when there is data pending on the
port (or handling other events separately).

I did something similar in ACE (Amstrad CPC Emulator) to implement
a BLooper with an "idle" handler (in order to keep a pattern implemented
by the original code for MorphOS).

-- 
Adrien.


Other related posts: