Codesnippets > Inline / 3rd party

Multithreading with GLBasic [official]

<< < (6/7) > >>

Interesting way of doing it. Well you've perked my interest in GLB threads again, I'll have a think on how I can use them in my game!  ;)

Actually I think that is the wrong way of approaching this, bigsofty. If you have a problem in your game that you can not solve any other way, than it may be worth to try it with multithreading. But you should not just include it, just because you want to. Threads add huge extra complexity, some overhead and many sources of possible bugs. In many cases threads dont get you anything, so you should avoid them if possible and only use them when really necessary.
BTW many GLBasic commands are not thread  save, so be careful what you pack inside a thread. That 'official' in the title is very misleading IMHO, since GLBasic was not designed with threads in mind.

Thanks Kanonet, I've used multithreading in other languages in the past which were thread safe and I do understand the risks with non-threads age code. I will probably avoid the GLB runtime lib altogether and even then stick to inline C. The single core restriction is a real pain TBH, even getting some of the CPU power back would be a real boost. But yes, I'm very restricted to mainly calculations and even then the 2nd thread has to be almost independent of the 1st with careful mutex handling. AND even then it will be labeled as experimental for a long time.

Thank you for you word of caution though.  ;)

Bumping, attachment isn't available :-(
As this is old post from few years back, and we got some core changes, like GCC behind GLB was updated, new platforms, and something regarding this topic could change as well in that time. So my question is: what's the current best multi-platform way of doing multi-threaded app with GLB - that would work for Win/Linux and Android. This lib, C++ inline with <threads> or SDL_threads.
And a general question, any one used threads in GLB in final/released product, or have additional examples (to just bundle it all up), is aware of any special restrictions, or have hints and tips for using multi-threading in GLB? I know that core drawing/media functions needs to be used in main thread only, my additional threads would do pure calculation stuff like pathfinding/collision checking (with use of Timer/Sleep functions and etc).

Kitty Hello:
I'd still go with the HtCreateThreads method. You might be able to implement OpenMP, but seriously, if you're dounf MT, you need to know what you do. It's not that easy if you want to avoid racing conditions etc.


[0] Message Index

[#] Next page

[*] Previous page

Go to full version