mirror of
https://github.com/scp-fs2open/fs2open.github.com.git
synced 2026-11-11 17:49:53 -10:00
This will ensure that Lua functions will always be executed in the correct Lua state. Since we now have multiple threads (which are different lua_State objects) it is possible that the current code could execute a Lua function in the main state instead of the thread that is currently executing. This can lead to weird behavior and probably also to issues inside Lua.
35 lines
759 B
C++
35 lines
759 B
C++
#include "tracing_category.h"
|
|
|
|
#include "tracing/tracing.h"
|
|
|
|
namespace scripting {
|
|
namespace api {
|
|
|
|
ADE_OBJ(l_TracingCategory, tracing::Category, "tracing_category", "A category for tracing engine performance");
|
|
|
|
ADE_FUNC(trace,
|
|
l_TracingCategory,
|
|
"function body()",
|
|
"Traces the run time of the specified function that will be invoked in this call.",
|
|
nullptr,
|
|
nullptr)
|
|
{
|
|
tracing::Category* category = nullptr;
|
|
luacpp::LuaFunction func;
|
|
if (!ade_get_args(L, "ou", l_TracingCategory.GetPtr(&category), &func)) {
|
|
return ADE_RETURN_NIL;
|
|
}
|
|
|
|
if (!func.isValid()) {
|
|
LuaError(L, "Invalid function reference passed!");
|
|
return ADE_RETURN_NIL;
|
|
}
|
|
|
|
TRACE_SCOPE(*category);
|
|
func(L);
|
|
return ADE_RETURN_NIL;
|
|
}
|
|
|
|
} // namespace api
|
|
} // namespace scripting
|