BASIC

Author Topic: Multithreading with GLBasic [official]  (Read 15033 times)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10713
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
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

  • Guest
Re: Multithreading with GLBasic [official]
« Reply #1 on: 2009-Oct-13 »
Does it work on the iphone?

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5021
  • O Rly?
    • View Profile
Re: Multithreading with GLBasic [official]
« Reply #2 on: 2009-Oct-13 »
Mutex are multiplatform
I <3 DGArray's :D

PC:
AMD Ryzen 7 1700 @3.9GHz, 16GB HyperX Fury 3000MHz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1635
  • Particle Hawk
    • View Profile
Re: Multithreading with GLBasic [official]
« Reply #3 on: 2009-Oct-13 »
Awesome!
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline metzzo

  • Mr. Polyvector
  • ***
  • Posts: 140
  • Coolo ist cool!
    • View Profile
    • programming with design
Re: Multithreading with GLBasic [official]
« Reply #4 on: 2009-Oct-13 »
Thank you gernot :)
That's no Bug, that's my project!

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

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2628
    • View Profile
Re: Multithreading with GLBasic [official]
« Reply #5 on: 2009-Oct-13 »
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)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10713
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Multithreading with GLBasic [official]
« Reply #6 on: 2009-Oct-14 »
I have not watched for thread safety, so I suggest using calculations and graphics exclusively in threads.

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1774
    • View Profile
    • Homepage
Re: Multithreading with GLBasic [official]
« Reply #7 on: 2010-Feb-28 »
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?

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10713
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Multithreading with GLBasic [official]
« Reply #8 on: 2010-Mar-01 »
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.

Offline S. P. Gardebiter

  • Mr. Polyvector
  • ***
  • Posts: 245
    • View Profile
    • Tile 44 Interactive
Re: Multithreading with GLBasic [official]
« Reply #9 on: 2010-Apr-19 »
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! ~

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10713
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Multithreading with GLBasic [official]
« Reply #10 on: 2010-Apr-20 »
Yes

Offline Kuron

  • Mr. Polyvector
  • ***
  • Posts: 238
    • View Profile
Re: Multithreading with GLBasic [official]
« Reply #11 on: 2010-Apr-20 »
I didn't realize this library existed.  I have been using my own threading routines  :D

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2628
    • View Profile
Re: Multithreading with GLBasic [official]
« Reply #12 on: 2012-Sep-21 »
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)

MrTAToad

  • Guest

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2628
    • View Profile
Re: Multithreading with GLBasic [official]
« Reply #14 on: 2012-Sep-23 »
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)