[A4/A5] How thread safe is Allegro?
Chris Katko

Both Allegro 4, and Allegro 5? How thread safe are we talking about? Can I blit to multiple bitmaps at the same time? Can I load files at the same time?

What happens when I blit to different sections of the same bitmap? (Mutex locked, I assume?)

Gideon Weems

There's actually a really good article on this. It's a shame the wiki doesn't get the attention it deserves.

Thomas Fjellstrom

I don't think A4 gives much thought to user threads. Some parts of the implementations use threads behind the scenes, but even then its a bit sketchy from what I remember. Locking is totally up to you.

As for A5, it was designed to be thread safe. Much state is stored in thread local variables. You can draw with hw in two different threads if you have two separate contexts set up. Otherwise you're stuck to a single thread drawing on a context at a time, with other threads using software.

SiegeLord

The nicest thing you can say about this is that Allegro5 aspires to be thread safe. It's straightforward to find parts that can race each other, however. I don't think many of those things can or should be fixed, but rather a better approach is to examine the common use cases and make sure they don't have thread-safety issues.

Thread #615096. Printed from Allegro.cc