Why is there sleep(0.001) in default love.run()?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
fuxoft
Prole
Posts: 3
Joined: Mon Jan 07, 2013 2:28 pm

Why is there sleep(0.001) in default love.run()?

Post by fuxoft »

Why is there the following line in the default love.run() function?

Code: Select all

if love.timer then love.timer.sleep(0.001) end
Is it just a failsafe to prevent the 100% CPU load when someone pumps new frames without vsync, as fast as possible? Or does it have more complex purpose?
User avatar
Lafolie
Inner party member
Posts: 809
Joined: Tue Apr 05, 2011 2:59 pm
Location: SR388
Contact:

Re: Why is there sleep(0.001) in default love.run()?

Post by Lafolie »

Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: Why is there sleep(0.001) in default love.run()?

Post by Boolsheet »

fuxoft wrote:Is it just a failsafe to prevent the 100% CPU load when someone pumps new frames without vsync, as fast as possible?
Yes, that's it. A very simple way to prevent LÖVE from wasting all the CPU cycles and it's in love.run so lovers can easily remove it, if they want to.
Shallow indentations.
Post Reply

Who is online

Users browsing this forum: slime and 3 guests