Skip to content
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

Add PriorityQueue #429

Closed
wants to merge 2 commits into from
Closed

Add PriorityQueue #429

wants to merge 2 commits into from

Conversation

trowski
Copy link
Member

@trowski trowski commented Jan 7, 2024

This adds a priority queue implementation which we've copied in some form or another to use as a queue for timeouts. We're currently using a simplified version in amphp/http-server and I've used similar code in some personal and work projects. @bwoebi would now like to use this in amphp/quic without having to copy the implementation yet again, so I'm proposing we add it here.

This queue implementation provides ordering of array-keys based on an updatable priority. These array keys may then be used with a separate map to reference any other value, such as an object.

@trowski trowski requested review from kelunik and bwoebi January 7, 2024 17:03
@kelunik
Copy link
Member

kelunik commented Jan 7, 2024

We ship a similar implementation as Timer Queue in Revolt. Should we place it there instead?

@trowski
Copy link
Member Author

trowski commented Jan 7, 2024

We could, though I hesitate to provide extra tools in revolt/event-loop which aren't directly related to the loop API. We could make it a separate library under Revolt. What do you think?

@trowski
Copy link
Member Author

trowski commented Jan 7, 2024

Quick note: The revolt loop uses a similar class, but is tailored for TimerCallback objects and uses floats for timer expirations. We could use this implementation there, but it would require multiplying timeouts by 1000 (or more?) and a map of timer IDs to TimerCallback.

@trowski
Copy link
Member Author

trowski commented Mar 12, 2024

Moving this to amphp/sync instead, see amphp/sync#27.

@trowski trowski closed this Mar 12, 2024
@trowski trowski deleted the priority-queue branch March 12, 2024 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants