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:
OldManAlpha
2025-09-19 12:35:36 -07:00
parent 2475043039
commit 4775b3ab7f
2 changed files with 29 additions and 14 deletions
+9 -2
View File
@@ -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