Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!news.albasani.net!.POSTED!not-for-mail From: Lew Newsgroups: comp.lang.java.gui Subject: Re: Coalescing Updates in MVC? Date: Sat, 26 May 2012 12:02:05 -0700 Organization: albasani.net Lines: 32 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net RfcumuU5h4foWCwEoQwdf3BGy6OMMl2kYXAULG2Wrjnrmz9ldhD48LKxVq1Na0x6EIoxMw3lmntMK4P6eU2rkqulmVT0RaIMeTa/87e8DbEglgXOUyEgxFq0j+xGnXgR NNTP-Posting-Date: Sat, 26 May 2012 19:02:06 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="m7OjfsUM69TLc4OI5pT+uvU3/qHv/uPonIrvGG9q7VpDFiVGi7uK6C6wxsxF/OmhFZKE7dhwJXDZCQM+xb/cjqfD/6IV//+0124MHzPVamBIpi6+9+iho8643UGpSl0S"; mail-complaints-to="abuse@albasani.net" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 In-Reply-To: Cancel-Lock: sha1:iBOi5A6S8sMYg2LNyebFbtzJVaY= Xref: csiph.com comp.lang.java.gui:5147 John B. Matthews wrote: > Stefan Ram wrote: >. . . >> How is this usually handled? > > java.awt.Component coalesces certain mouse and paint events in > coalesceEvents(), which is called by EventQueue.postEvent(). > > When using javax.swing.Timer, isCoalesce() is true by default. In > practice, this degrades gracefully on slower hardware. I'm not sure coalescing model events is necessarily faster than processing them, depending on how things are staged and parallelized. An event-processor loop can detect that it has multiple events pending when it tries to fetch one, and attempt to coalesce some before applying them to the model. But then you sort of need to model the effects of each event to know how they can coalesce, which is already the job of the model. In the AWT case John mentions, it is view events that are coalesced. This makes sense - the graphics engine has a model of the display with which it can outpace the actual display using offscreen buffers and other tricks. So the "M" part of the system applies its changes sequentially and atomically, firing off change notifications but not actually changing the "V" part. The model thus stays nimble and up to date. The "V" part is perforce slower, but the processing engine can coalesce events if it's faster than the display. -- Lew Honi soit qui mal y pense. http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg