I want to queue up some async tasks: however i’d like to push them in queues such that the order within a queue is conserved.
Concretely, my problem are async plots into a Makie axis. My starting point is something like that:
function event_function(ax)
@async begin
# multiple commands manipulating axis object ax
end
end
The problem arises when events are triggered in quick succession and the async tasks might overlap. What I tried next is something like this:
queue = Channel{Function} do ch
while isopen(ch)
task = take!(ch)
invoke_latest(task)
end
end
function event_function(ax)
put!(queue, () -> begin
# multiple commands manipulating axis object ax
end)
end
but it feels a bit hacky with the invoke_latest
and so on. Is there a “default” way of achieving this kind of behavior? Or maybe a package providing a nice abstraction for such a “task queue”?