Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Allegro 5 thread on other languages

This thread is locked; no one can reply to it. rss feed Print
Allegro 5 thread on other languages
Niunio
Member #1,975
March 2002
avatar

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?

-----------------
Current projects: Allegro.pas | MinGRo

gillius
Member #119
April 2000

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.

Gillius
Gillius's Programming -- https://gillius.org/

SiegeLord
Member #7,827
October 2006
avatar

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.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Niunio
Member #1,975
March 2002
avatar

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. ???

-----------------
Current projects: Allegro.pas | MinGRo

Elias
Member #358
May 2000

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.

--
"Either help out or stop whining" - Evert

Niunio
Member #1,975
March 2002
avatar

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

-----------------
Current projects: Allegro.pas | MinGRo

Go to: