Hello,
Thanks for the reply, as I thought, this would be too difficult to implement and I do need 64bit support so preemptive kernel in not an option. I've thought more about this, and actually I think the 20ms per script shouldn't even be a problem anymore since code execution of scripts shouldn't even take a ms. The only exception to that would be the sleep calls in scripts would need to be implemented differently but it should all be fine. I think script loading and updating can all be done in the main thread but for scripts that need to use sleep calls, I will create one worker thread with a queue implementation which handles all of this. Scripts could then use it like so:
void do_stuff()
{
//this will run in a seperate worker thread;
...do stuff here
Sleep(500);
.. etc etc
}
void Update()
{
static float lastRan = 0;
float timeNow = timeGetTime();
if(timeNow - lastRan >= 5000) //every 5 seconds
{
ExecThread(do_stuff);
lastRan = timeNow;
}
}