Asynchronous tasks
#8
You could already do a few things to avoid lag - for example make the command create a description of the operation, store it in a storage and have the world tick thread do a little bit of work on the queue of such operations at a time - for example generating, say, 10 slices of a big area.
function OnCmdGenerate(...)
  local operation = cGenerateStructure:new(...)
  table.insert(g_WorkQueue[worldName], operation)
end

function OnWorldTick(...)
  local workItem = g_WorkQueue[worldName][1]
  if (workItem ~= nil) then
    workItem:doABitOfWork()
    if (workItem:IsFinished()) then
      table.remove(g_WorkQueue, 1)
    end
  end
end
Reply
Thanks given by:


Messages In This Thread
Asynchronous tasks - by Howaner - 03-11-2015, 05:58 AM
RE: Asynchronous tasks - by NiLSPACE - 03-11-2015, 06:12 AM
RE: Asynchronous tasks - by worktycho - 03-11-2015, 06:16 AM
RE: Asynchronous tasks - by NiLSPACE - 04-12-2015, 12:39 AM
RE: Asynchronous tasks - by xoft - 04-12-2015, 01:31 AM
RE: Asynchronous tasks - by NiLSPACE - 04-12-2015, 09:54 PM
RE: Asynchronous tasks - by xoft - 04-13-2015, 12:50 AM
RE: Asynchronous tasks - by xoft - 04-13-2015, 12:54 AM
RE: Asynchronous tasks - by NiLSPACE - 04-13-2015, 01:29 AM
RE: Asynchronous tasks - by worktycho - 04-15-2015, 09:49 AM
RE: Asynchronous tasks - by NiLSPACE - 04-15-2015, 05:46 PM
RE: Asynchronous tasks - by worktycho - 04-15-2015, 07:45 PM
RE: Asynchronous tasks - by xoft - 04-15-2015, 08:06 PM
RE: Asynchronous tasks - by worktycho - 04-15-2015, 08:24 PM
RE: Asynchronous tasks - by NiLSPACE - 04-15-2015, 08:26 PM
RE: Asynchronous tasks - by worktycho - 04-15-2015, 08:34 PM
RE: Asynchronous tasks - by NiLSPACE - 04-15-2015, 09:13 PM
RE: Asynchronous tasks - by worktycho - 04-15-2015, 09:16 PM
RE: Asynchronous tasks - by NiLSPACE - 04-15-2015, 09:24 PM
RE: Asynchronous tasks - by worktycho - 04-15-2015, 09:36 PM
RE: Asynchronous tasks - by xoft - 04-15-2015, 09:48 PM
RE: Asynchronous tasks - by worktycho - 04-15-2015, 09:59 PM
RE: Asynchronous tasks - by NiLSPACE - 09-28-2015, 08:10 PM
RE: Asynchronous tasks - by xoft - 09-28-2015, 09:53 PM
RE: Asynchronous tasks - by NiLSPACE - 09-28-2015, 10:00 PM
RE: Asynchronous tasks - by worktycho - 09-28-2015, 10:09 PM



Users browsing this thread: 1 Guest(s)