Hello there my lövelies!
I've been messing around with lua-enet recently, and I've been slowly adapting the initial example on the wiki into my own program - however, I'm confused about host:service() - I found that setting a timeout value makes it wait for incoming events, but leaving it as nil will make it not wait but still recieve events. The example uses a timeout of 100, but I found my own program worked much better leaving it nil.
In short, what's the point of timeout? If it does turn out to be important, I'll look into multithreading so it doesn't disturb the framerate in the way it currently does.
What's point of timeout?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
What's point of timeout?
Dragon
Re: What's point of timeout?
I haven't looked into lua-enet, but if that timeout is what I think it is (i.e. internally passed to a select() call) then it's intended for pausing the thread until either something is received, or the timeout expires, whichever comes first. It's useful in the case of a multithreaded application with a thread dedicated entirely to listening, or in the case of an application which can afford pausing while communicating through a socket. That pause makes the thread not suck CPU resources during the wait; if it was in a tight loop constantly monitoring whether there's data ready, it would consume CPU, but this way, the OS can let other threads/processes run while that one is waiting.
In your case, if you want it in the main thread, you probably don't need a timeout; you can simply use love.update() to check if there's something waiting and that works just fine. The Löve gameloop already takes care of not sucking CPU time, by waiting for Vsync or 1ms. So, nil should be OK.
In your case, if you want it in the main thread, you probably don't need a timeout; you can simply use love.update() to check if there's something waiting and that works just fine. The Löve gameloop already takes care of not sucking CPU time, by waiting for Vsync or 1ms. So, nil should be OK.
Who is online
Users browsing this forum: Bing [Bot] and 33 guests