[haiku-commits] Re: BRANCH looncraz-github.setviewuicolor [f68a3bb52ec4] src/servers/app

  • From: Hamish Morrison <hamishm53@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 29 Sep 2015 12:23:17 +0100

Hi looncraz,

Implemented DelayedMessageThread
* Single thread, low priority, used to intelligently awaken and process
* pending messages for all DelayedMessageLoopers.

Delayed messages are also now properly merged, and the one delayed
message currently being sent (B_COLORS_UPDATED) has a near 50% merge
rate while dragging the color control constantly. The result is that
CPU usage is much reduced and the changes to the system appear much
more smoothly and quickly.

I will be piggy-backing on this sysem for a DelayedInvalidate()
implementation as well. There are probably plenty of places where
delaying the sending of a message (however lazily and inaccurately)
as well as merging those messages will be of great use. As it becomes
more used, it may be necessary to increase the priority, or to create
more than one thread... for now, though, it's overkill :p

Perhaps instead of having a separate thread to dispatch the delayed
messages, the looper could read from its port with a timeout equal
expiry time of the next delayed message? Then on return, it could
dispatch any messages that have now expired. This would avoid having
an extra thread and the potential scalability issues that go along
with that.

This could also be generally useful as a lightweight timer mechanism
instead of the heavy BMessageRunner.

Cheers
Hamish

Other related posts: