Re: pgserver behaviour

Tom?? Stan?k <[email protected]>
Newsgroups gmane.comp.video.picogui.devel
Message-ID <[email protected]>
> > pgEventLoop() blocks your program and processes all events until pgExitEventLoop() is called. pgEventPoll() processes any available events and returns as soon as possible. You shouldn't use "while (1) pgEventPoll()" since that will make your program use 100% of the CPU checking for new events.
> > 
> sure, about that CPU usage you can think of while (1) { pgEventPoll(); usleep(10000); } and it behaves same (just less cpu consiming)
> my point was that pgEventLoop() behaves different than while(1) { pgEventPoll(); usleep(10000); }
> (if you add sleep call to while in the test.c i sent, it will do the same thing)
> 
i have taken a look at the cli_c code. i guess the answer is: because the the pgEventLoop flow is:
pgGetEvent
	pgUpdate
	wait for event
pgDispatchEvent
	do stuff in my function
pgGetEvent
	pgUpdate (updates changes my function made)
	wait for event
.....
and the while flow:
pgCheckEvent - no
pgCheckEvent - no
pgCheckEvent - yes => 
	pgGetEvent
		pgUpdate
		wait for event which is here
	pgDispatchEvent
		do stuff in my function
(no pgUpdate for latest changes)
pgCheckEvent - no
.....



-------------------------------------------------------
This SF.net email is sponsored by: SlickEdit Inc. Develop an edge.
The most comprehensive and flexible code editor you can use.
Code faster. C/C++, C#, Java, HTML, XML, many more. FREE 30-Day Trial.
www.slickedit.com/sourceforge
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.