I currently have a program that has four content loading threads(to reduce lag), and one rendering thread. I just found out that the reason why my program was using 20% more CPU was because the ALLEGRO_FONT does not have the current display set, because it's loaded in the content thread, which does not have a current display. So I set the display and then I start to see a lot of crashing. Well, now I have just found out this is because I call al_hold_bitmap_drawing(true) in the rendering thread, and that interferes when loading bitmaps/fonts. So, my whole method is screwed now, and I pretty much need to redo my whole base of the program, woohoo!
Since the four content threads are pretty much useless, I'm going to get rid of those and do the content loading in the rendering thread. Now, before I went and jumped on programming that, I was thinking about how I can make sure that lag doesn't happen here. This is where my problem comes in. How can I make sure that whenever the redrawTimer is set off that it will stop loading the bitmap, if its trying to load one, and redraw? A friend of mine mentioned making a queue to set priorities on, or even having two queues, checking the first one first since it has higher priority. That solves that but I still need to make sure that the al_load_bitmap or al_load_font function won't take longer than needed. Since the FPS is 20, if it starts loading a bitmap right when a redraw event is emitted, it could stop the thread and it'd have to wait a bit longer to be redrawn. Is there anyway to do this?
I do apologize about the title of this thread, I was not sure what to name the topic.