Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Blocking  (Read 2851 times)

0 Members and 1 Guest are viewing this topic.

Recruit0

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Blocking
« 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?

Mindiell

  • Hero Member
  • *****
  • Posts: 1261
    • ICQ Messenger - 41484135
    • View Profile
Blocking
« Reply #1 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 ?
Mindiell
----

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Blocking
« Reply #2 on: August 23, 2010, 02:17:42 pm »
A blocking WaitEvent function is available in SFML 2.
Laurent Gomila - SFML developer

Recruit0

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Blocking
« Reply #3 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.