SFML community forums

General => General discussions => Topic started by: Recruit0 on August 23, 2010, 01:52:56 am

Title: Blocking
Post by: Recruit0 on August 23, 2010, 01:52:56 am
Do we have the ability to put our program into the blocked state? This would be useful for non-game applications (so they don't suck up CPU).

IIRC we can call sleep( time ) but that's not really how it's supposed to work. It's not *really* getting blocked, it's just activating a timer to sleep every so many seconds (it's only partially blocked). It should stay in the blocked state until it has an event to handle.

If this isn't available in SFML stable then can it be in the next release?
Title: Blocking
Post by: Mindiell on August 23, 2010, 08:59:38 am
I don't really understand what you are saying by "really blocked", since the application must continue to handle events to be un-blocked.

The only thing you have to do is a loop with a sleep, waiting a specific event. If the app s blocked, nothing will un-block it, it must wait for a signal or something, no ?
Title: Blocking
Post by: Laurent on August 23, 2010, 02:17:42 pm
A blocking WaitEvent function is available in SFML 2.
Title: Blocking
Post by: Recruit0 on August 23, 2010, 03:04:40 pm
Quote from: "Mindiell"
The only thing you have to do is a loop with a sleep, waiting a specific event. If the app s blocked, nothing will un-block it, it must wait for a signal or something, no ?
It will wake up after however long you tell it to sleep. As in, it's not going to wake up from an event signal, but an alarm clock (which is "wrong" when it comes to event driven programming). The sleep() function (in any library) does not tell it to wait for a specific event (from the user), it means "block me for a minimum amount of time".

Quote
A blocking WaitEvent function is available in SFML 2.
Thanks for the addition in SFML 2.