|
Doing stuff while drawing is halted |
jmasterx
Member #11,410
October 2009
|
I notice that when drawing is halted, e.g., an app is in the background, Allegro blocks until you return. The problem with that for me is that RakNet is paranoid and if it does not hear from me in a timely manner, it will drop my connection. Therefore, if a user goes to the background for about 5 seconds, they get kicked from the server which is not desired. Is there some way I can continue to call my net->tick(); function while my App is in the background? I can always start a thread to do it, but I would prefer not to involve multithreading if possible. Agui GUI API -> https://github.com/jmasterx/Agui |
Thomas Fjellstrom
Member #476
June 2000
|
Do you know where it is blocking? al_wait_for_event perhaps? I know you get an event when you switch out, and drawing is halted.. if you notice that, you can probably just skip the al_wait_for_event and just start polling raknet occasionally? Or instead of a plain al_wait_for_event you use al_wait_for_event_timed to let it timeout and then process raknet. -- |
jmasterx
Member #11,410
October 2009
|
Thanks! al_wait_for_event_timed was just what I was looking for! The reason I need it is I need to receive the event when things resume. Agui GUI API -> https://github.com/jmasterx/Agui |
Thomas Fjellstrom
Member #476
June 2000
|
You should always get a resume event when things resume. -- |
jmasterx
Member #11,410
October 2009
|
From what I can see from testing, a few seconds after calling al_acknowledge_drawing_halt Allegro just pauses all execution on all my threads, I even tried creating a thread that jus prints hello and even that stopped printing a few seconds later and started printing again when I returned. It is not iOS doing this, I made a test and eliminating Allegro lets me do stuff when I'm in the background. So right now I have to way to keep the network thread alive If I omit acknowledging the halt, my networking keeps running fine, but then I can never get the resume because I never called the acknowledge_halt... Odd thing though is I don't see anything in Allegro's source that indicates it locks threads on drawing halt. Agui GUI API -> https://github.com/jmasterx/Agui |
Elias
Member #358
May 2000
|
ALLEGRO_EVENT_DISPLAY_HALT_DRAWING is done whenever ios sends this to the application: [1] Quote: If the method does not return before time runs out your app is terminated and purged from memory. So no, just continuing is not an option, according to Apple. You probably have to register your app as a special background application (those displaying a little icon at the top) to keep any network activity while it is switched out. I don't know details how to do it, but a normal application definitely cannot keep running in the back under iOS. -- |
jmasterx
Member #11,410
October 2009
|
Thanks for the info. I was not aware of how all that worked. Agui GUI API -> https://github.com/jmasterx/Agui |
Thomas Fjellstrom
Member #476
June 2000
|
Ah, I wasn't thinking this was on mobile. Yeah, you basically need to take that into account... -- |
|