-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade queue mechanism, to return more buffers #3
Conversation
4a08198
to
970b60b
Compare
970b60b
to
deb504e
Compare
1ac3cdf
to
2c01685
Compare
lib/membrane/timestamp_queue.ex
Outdated
An item that is not a buffer is considered available if all buffers from the same pad, | ||
which are newer than the item are available. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An item that is not a buffer is considered available if all buffers from the same pad, | |
which are newer than the item are available. | |
An item other than a buffer is considered available if all newer buffers on the same pad are available. |
lib/membrane/timestamp_queue.ex
Outdated
{actions, timestamp_queue} = actions_after_popping_buffer(timestamp_queue, pad_ref) | ||
{actions ++ actions_acc, timestamp_queue} | ||
end) | ||
defp do_pop_batch(%__MODULE__{} = timestamp_queue, actions_acc \\ [], items_acc \\ []) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd avoid default values in recursive functions, as it's easy to reset an accumulator by accident
lib/membrane/timestamp_queue.ex
Outdated
|> do_pop() | ||
end | ||
end | ||
|> do_pop_batch(actions_acc, items_acc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes the flow harder to follow, can we return the accumulators here to do_pop_batch
instead, so that each function only calls itself recursively?
lib/membrane/timestamp_queue.ex
Outdated
first_item_on_awaiting_pad_qex? = | ||
pad_ref in timestamp_queue.awaiting_pads and pad_queue != nil and pad_queue.qex == Qex.new() | ||
|
||
timestamp_queue | ||
|> put_in([:pad_queues, pad_ref], new_pad_queue()) | ||
|> Map.update!(:pads_heap, &Heap.push(&1, {priority, pad_ref})) | ||
if first_item_on_awaiting_pad_qex? or not is_map_key(timestamp_queue.pad_queues, pad_ref) do | ||
priority = | ||
case item do | ||
{:buffer, buffer} when first_item_on_awaiting_pad_qex? -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These conditions are hard to read, can you try to refactor that?
Relates to membraneframework/membrane_core#734