mirror of
https://github.com/cuberite/cuberite.git
synced 2025-01-07 03:16:55 +08:00
Added small plugin to show multithreading
This commit is contained in:
parent
64ff027e64
commit
3fa47b4c8d
1
Server/Plugins/.gitignore
vendored
1
Server/Plugins/.gitignore
vendored
@ -5,3 +5,4 @@
|
||||
!/HookNotify
|
||||
!/NetworkTest
|
||||
!/TestLuaRocks
|
||||
!/MultiThreadTest
|
40
Server/Plugins/MultiThreadTest/init.lua
Normal file
40
Server/Plugins/MultiThreadTest/init.lua
Normal 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
|
Loading…
Reference in New Issue
Block a user