1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-08-20 06:47:09 +02:00

Rewrite logger to account for multiple-threads.

Implement error handling for worker VMs.
This commit is contained in:
Sandu Liviu Catalin
2020-09-08 22:44:04 +03:00
parent 054a7983a5
commit d6f3f52eec
8 changed files with 482 additions and 178 deletions

View File

@@ -108,11 +108,26 @@ struct EvaluateJob : public BaseJob
*/
bool Start(HSQUIRRELVM vm, Worker & worker) override
{
sq_compilebuffer(vm, mCode.data(), mCode.size(), mName.data(), SQTrue);
SQRESULT r = sq_compilebuffer(vm, mCode.data(), mCode.size(), mName.data(), SQTrue);
// See if the code could be compiled
if (SQ_FAILED(r))
{
return false; // Job failed
}
// Backup the stack top
SQInteger top = sq_gettop(vm);
// Push the root table as environment
sq_pushroottable(vm);
sq_call(vm, 1, false, true);
// Attempt to invoke the compiled code
r = sq_call(vm, 1, SQFalse, SQTrue);
// Restore the stack top
sq_settop(vm, top);
// See if the code could be evaluated
if (SQ_FAILED(r))
{
return false; // Job failed
}
// Job completed
return true;
}
};