With any game-- and most real-time applications, for that matter-- you will always want some kind of /rest(1)/ (to rest ~one millisecond). This saves CPU cycles, batteries, and makes fans less noisey. My latest ENet game does it this way:

   /while ( !_main_loop_exit ) {
        while ( enet_host_service(client, &event, 0) > 0 ) {
   ...
        }

        logic();
        display();
   //
        rest(1);
   }
   /


The biggest up side of ENet not wasting time waiting for something to happen is other time-critic sections of code have a chance to do something without having to wait (as is implied by this statement my application is single-threaded). As long as the other code does not take too long this allows ENet to check for a new events a hell of a lot of times each second (as is bound by the CPU).

------------------------------------------------------------------------

Nicholas J Ingrassellino
LifebloodNetworks.com <http://www.lifebloodnetworks.com/> || [email protected] <mailto:[email protected]>

"The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying."
- John Carmack on software patents


On 11/05/2010 12:28 PM, Вячеслав Блинников wrote:
I tried to set "0" but in such case cycle with "enet_host_service()"
consumes 100% of processor's power.
I did not understood the phrase "I haven't noticed any performance
issues with ENet" - you meant that there is nothing faster then ENet?

5 ноября 2010 г. 19:21 пользователь Ruud van Gaal<[email protected]>  написал:
I always use 0 for the enet_host_service() delay. And as for delays, I
haven't noticed any performance issues with ENet, although I'm doing a game
where framerate is very important.
Ruud
_______________________________________________
ENet-discuss mailing list
[email protected]
http://lists.cubik.org/mailman/listinfo/enet-discuss
_______________________________________________
ENet-discuss mailing list
[email protected]
http://lists.cubik.org/mailman/listinfo/enet-discuss

Reply via email to