Threads

BlitzMax Forums/BlitzMax Programming/Threads

JoshK(Posted 2007) [#1]
I was wondering if Mark's megatextures demo was loading the textures from the hard driver on a separate thread. Also, is multithreading possible through a C dll or static library?

We have some features we are investigating that would make good use of multithreading.


Gabriel(Posted 2007) [#2]
Also, is multithreading possible through a C dll or static library?

Yes, but the GC is not thread-safe, so you would have to handle all object management yourself. In practice, this is harder than you might think because BlitzMax does not have weak references so managing the objects yourself means one of two things. Either your library has to have explicit destroy methods and users won't be able to use the GC for any of your library's objects, or you have to have a pretty complex system which reference counts every object and then probably use proxy objects which only ever have one reference to actually pass around in your threads. In short, it seemed an awful lot of trouble when I was looking at it, and I ended up only doing it for one type of object ( textures ) and everything else has explicit destroy methods. That's cool for me because I'm the only one using my engine, but that's not the case for you, so it could be an awful lot of work for you unless I've missed an easier way of doing it.


JoshK(Posted 2007) [#3]
We're looking into megatextures loaded on a separate thread. A C static lib would be nice if it is possible.


FlameDuck(Posted 2007) [#4]
What Gabe said. BlitzMAX is ridiculously thread unfriendly. To the point where you get really frustrated.


JoshK(Posted 2007) [#5]
I don't understand. The lib would be written in C/C++. I don't expect BlitzMax to handle memory in the lib itself. It would be like using a third party SDK like Newton.