fix recursive queue flush (#28)

* fix recursive queue flush

* remove print from test

* swap order of flush

* simplified test case and remove error

* write more in-depth tests

* change approach flush_update_queue

* double diamond test case

* fix indent

* change naming of function

* subsequent updates do not batch test case

* simplify test case
This commit is contained in:
alicesaidhi 2024-08-20 13:44:56 +02:00 committed by GitHub
parent b85419088c
commit fbe2f01bb9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 219 additions and 16 deletions

View file

@ -6,17 +6,18 @@ local graph = require(script.Parent.graph)
local function batch(setter: () -> ())
local already_batching = flags.batch
local from
flags.batch = true
if not already_batching then
flags.batch = true
from = graph.get_update_queue_length()
end
local ok, err: string? = pcall(setter)
if not already_batching then
flags.batch = false
if not already_batching then
graph.flush_update_queue()
end
graph.flush_update_queue(from)
end
if not ok then throw(`error occured while batching updates: {err}`) end