I did some Googling earlier tonight regarding using the RTL and threads without creating a TThread class. I found some older results from this mailing list such as...<div><br><div><a href="http://www.hu.freepascal.org/lists/fpc-pascal/2010-October/026712.html">http://www.hu.freepascal.org/lists/fpc-pascal/2010-October/026712.html</a></div>
</div><div><br></div><div>Basically, what I want to know is "HOW DO I..." ensure the RTL memory management is safe if multiple threads are running, but if a TThread class is never instantiated. I am doing some work test/writing pascal demos for SDL 2.0 and it creates threads for you, sometimes automatically, which can call back user defined functions.</div>
<div><br></div><div>I've written a few example programs using just a program unit containing "uses SDL2;" (SDL2.pas only imports functions from a SDL 2.0 dynamic library) which play sounds, use force feedback controllers, accept touch input ect, and should work natively on many devices (Windows, Linux, Android, OSX, iOS, Raspberry Pi) with very little to no need for code modification. But, I want to be proper and ensure things something like the pascal memory manager works with GetMem and FreeMem (or for that matter all other rtl routines) when the SDL sound mixer calls back some of my user defined pascal function from a new thread SDL is managing.</div>
<div><br></div><div>My examples currently weigh in at about 25KB compiled and are quite concise/understandable. I'd like to avoid the baggage of bringing in the SysUtils and Classes units, creating a Classes.TThread, then destroying the thread ... all to ensure the memory manager and the rest of the System unit is aware multiple threads might be executing.</div>