Added small plugin to show multithreading

This commit is contained in:
Niels Breuker 2022-10-02 12:58:42 +02:00
parent 64ff027e64
commit 3fa47b4c8d
2 changed files with 41 additions and 0 deletions

View File

@ -5,3 +5,4 @@
!/HookNotify
!/NetworkTest
!/TestLuaRocks
!/MultiThreadTest

View File

@ -0,0 +1,40 @@
local PLUGIN_NAME = "MultiThreadTest";
function Initialize(a_Plugin)
a_Plugin:SetName(PLUGIN_NAME)
cPluginManager:BindConsoleCommand("startthread", HandleStartThreadCommand, "");
LOG("Initialized");
return true;
end
function Callback()
cRoot:Get():GetDefaultWorld():QueueTask(function()
print("From world thread");
end);
end
function HandleStartThreadCommand(a_Split)
cThread.new(function()
print("Test");
for i = 1, 5 do
cThread.sleep(1);
print("Testing", i);
end
-- Really ugly way to return to the default lua_State
cPluginManager:CallPlugin(PLUGIN_NAME, "Callback");
end)
return true;
end