Skip to content

treeset: avoid using goroutine / channel / context for iteration#60

Merged
shoenig merged 1 commit intomainfrom
treeset-no-goroutine
May 8, 2023
Merged

treeset: avoid using goroutine / channel / context for iteration#60
shoenig merged 1 commit intomainfrom
treeset-no-goroutine

Conversation

@shoenig
Copy link
Copy Markdown
Contributor

@shoenig shoenig commented May 7, 2023

This PR swaps implementations of TreeSet.iterate to not require a background goroutine, channel, and context. Instead we use an explicit stack and a generator function to "pull" values one at time. Unlike with the goroutine, the stack object is garbage collected automatically if we do not traverse the entire tree.

Inspiriation is from golang/go#56413

This PR swaps implementations of TreeSet.iterate to not require a background
goroutine, channel, and context. Instead we use an explicit stack and a
generator function to "pull" values one at time. Unlike with the goroutine,
the stack object is garbage collected automatically if we do not traverse
the entire tree.

Inspiriation is from golang/go#56413
@shoenig shoenig force-pushed the treeset-no-goroutine branch from 609db6a to 71a4421 Compare May 7, 2023 02:45
@shoenig
Copy link
Copy Markdown
Contributor Author

shoenig commented May 7, 2023

@zonewave for some reason I can't add you as a reviewer ... but if you don't mind taking a look that would be helpful 🙂

Copy link
Copy Markdown
Contributor

@zonewave zonewave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's great, and I think we can look into refactor the iterate, infix, forEach method that are repeated

@shoenig shoenig merged commit 84a76ab into main May 8, 2023
@shoenig shoenig deleted the treeset-no-goroutine branch April 15, 2024 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants