blob: 69bd20c0c4918ef23a495f61555a68502765e695 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
local subscribe_for_modification = mesecons_debug.settings._subscribe_for_modification
local gc_interval = mesecons_debug.settings.gc_interval
local cleanup_time_micros = gc_interval * 1000000
subscribe_for_modification("gc_interval", function(value)
gc_interval = value
cleanup_time_micros = value * 1000000
end)
local context_store = mesecons_debug.context_store
local cleanup_timer = 0
minetest.register_globalstep(function(dtime)
cleanup_timer = cleanup_timer + dtime
if cleanup_timer < gc_interval then
return
end
cleanup_timer = 0
local now = minetest.get_us_time()
for hash, ctx in pairs(context_store) do
local time_diff = now - ctx.mtime
if time_diff > cleanup_time_micros then
-- remove item
context_store[hash] = nil
mesecons_debug.context_store_size = mesecons_debug.context_store_size - 1
end
end
end)
|