Aux no longer consumes resources when not in use
Aux would perform unnecessary tasks every frame even when not in use. This has been solved by only running those tasks when Aux is actually doing things.
This commit is contained in:
+9
-2
@@ -2,7 +2,7 @@ module 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local event_frame = CreateFrame'Frame'
|
||||
local event_frame = CreateFrame('Frame', 'AuxThreadingFrame')
|
||||
|
||||
local listeners, threads = T.acquire(), T.acquire()
|
||||
|
||||
@@ -10,7 +10,6 @@ local thread_id
|
||||
function M.thread_id() return thread_id end
|
||||
|
||||
function handle.LOAD()
|
||||
event_frame:SetScript('OnUpdate', UPDATE)
|
||||
event_frame:SetScript('OnEvent', EVENT)
|
||||
end
|
||||
|
||||
@@ -39,6 +38,11 @@ do
|
||||
for id, thread in threads do
|
||||
if thread.killed or not thread.k then
|
||||
threads[id] = nil
|
||||
local hasLiveThread = false
|
||||
for _ in pairs(threads) do hasLiveThread = true break end
|
||||
if not hasLiveThread then -- Disable threading task so it doesn't consume resources doing nothing
|
||||
event_frame:SetScript('OnUpdate', nil)
|
||||
end
|
||||
else
|
||||
local k = thread.k
|
||||
thread.k = nil
|
||||
@@ -100,6 +104,9 @@ do
|
||||
arg.f = tremove(arg, 1)
|
||||
local thread_id = unique_id()
|
||||
threads[thread_id] = T.map('k', setmetatable(arg, mt))
|
||||
if event_frame:GetScript("OnUpdate") == nil then -- Spin up threading if it was turned off
|
||||
event_frame:SetScript('OnUpdate', UPDATE)
|
||||
end
|
||||
return thread_id
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user