Multithreading with GLBasic [official]

Previous topic - Next topic

Kitty Hello

Hi,

This is a library that provides multithreading and thread synchronization functions for GLBasic (premium).

I can't find if I ever posted this before, but here is the place it belongs to.

keywords:
thread, mutex, condition, ThThreadCreate




[attachment deleted by admin]

MikeHart


Schranz0r

I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Hemlos

Bing ChatGpt is pretty smart :O

metzzo

That's no Bug, that's my project!

http://programming-with-design.at/

bigsofty

Thank you Gernot!  :good:

In the way of advice, is there anything In the RTL I would be better to avoid running in a separate thread?
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Kitty Hello

I have not watched for thread safety, so I suggest using calculations and graphics exclusively in threads.

Moru

This thread library was very easy to get started in, thanks! Had my program running within 5 minutes :-)
Just a few questions:

1. Is it possible to stop a thread from outside the thread?

2. When ending a thread, do I just need to let the subroutine run to the end or do I need to do something special?

3. I'm assuming the ThMutexLock() will halt execution until the mutex is free?

Kitty Hello

1. You can do that with a condition. One thread informs the other about a quit flag.
2. yes. Just return in the sub and you're done.
3. right. The mutex lock will pause until you can access the mutex. That way you can lock shared memory.

S. P. Gardebiter

Hello, I've got a question:
So multithreading is an official part of GLBasic and has the same licence conditions?
Means: Everything I can do with GLBasic, I can do with this libary as well?
~ Cave Story rules! ~

Kitty Hello


Kuron

I didn't realize this library existed.  I have been using my own threading routines  :D

bigsofty

Quick question: What is the name of the C lib that this uses within the in-line code? I was wanting to try and gather some docs on the C side for a better understanding of the of in-lined sections if possible.
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)


bigsofty

Could be!  :good:

Um after a quick websearch, it looks like this(or not?).  :S

http://hawksoft.com/hawkthreads/
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)