Allegro 5 thread on other languages
Niunio

This is a quite simple question.

Allegro includes a cross-platform threading interface. Object Pascal defines it's own cross-platform threading interface too, so I wonder if it would be any problem by using it. As I've seen at Free Pascal sources it uses Windows threads on Windows and pthreads on POSIX as Allegro. Anyway, is there anything I should care about using threads with Allegro?

Also, what about other languages?

gillius

I've started developing jalleg, the Java binding for Allegro 5.2 and I've been able to successfully use Java's native threads on Allegro. By that I mean I've created other threads in Java and called Allegro routines and not seen any problems, but I wouldn't call that extensive testing.

As far as I know Allegro's thread interaction is about thread locals. As long as Allegro's implementation is associated with the OS native threads, then it should not matter what API you use to create threads.

SiegeLord

Yeah, using your language's threads should work fine.

The threading API is one of a few bits of Allegro that were necessary internally, but were exposed externally because they seemed useful, even if you typically might not use them in a typical program/game.

Niunio

Good to know. Thanks. :)

Anyway, I was trying to understand how does it work, to translate the examples correctly, and I found it a bit confusing. ex_native_filechooser creates a lot of threads, and I just don't know why. ???

Elias

The native file chooser is a special case - for some reason al_show_native_file_dialog blocks the calling thread. So if you call it from the main thread you more or less kill your game (can't handle events or anything while the dialog shows). To avoid that the example calls the function from another thread.

Niunio

I see. I should study it and find the way to port it to Pascal, as that dialog is quite useful.

Thread #616349. Printed from Allegro.cc