Thread: [ocemp-devel] RFP: optimal event distribution loop
Status: Beta
Brought to you by:
marcusva
From: Regis D. <rde...@be...> - 2006-10-06 08:24:31
|
Hello, This is the event distribution loop we use in our ocempgui-based projet: while renderer.distribute_events(pygame.event.wait()): pass pygame.event.wait() offers the advantage to return when (and only when) a new event is available, whereas pygame.event.get() returns immediately (mostly None). The pygame.event.wait() approach consumes as few CPU time as possible as it is based on thread synchronization mechanisms provided by the host operating system. I'm not sure, but the existing pygame.event.get() approach seems to be designed to allow tuning such as FPS. There is a polling which is not that much CPU time friendly. It would be nice to integrate such a loop either: * In replacement of the existing Renderer._loop() method (if internal timer no longer required). * In combination of the existing Renderer._loop() method (if internal timer still required). * As an alternative Renderer._loop() method - say Render._synchronizedLoop(). * As an EventDistributionPolicy passed at Renderer construction time. * ... Yours to provide more details, Regis. -- ------------------------------------------------------------------------ Regis C. Desgroppes, software geek Parkeon (former Schlumberger e-City) - AFC - R&D ------------------------------------------------------------------------ no software patents <http://www.nosoftwarepatents.com> Given enough eyeballs, all bugs are shallow. (Eric S Raymond) |