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

workerpool: refactor results to avoid unnecessary copy #11

Merged
merged 1 commit into from
Feb 11, 2021

Conversation

kaworu
Copy link
Member

@kaworu kaworu commented Feb 11, 2021

Background: To avoid leaking the internal implementation of the task struct, WorkPool.Drain() return a slice of Task interface.

Before this patch, the WorkPool struct would maintain a slice of concret task struct pointers to be used as return value for the Drain() method. Since Drain() returns a slice of Task interface, a conversion was required.

This patch make it so the WorkPool results is a slice of Task interface instead. That way it can be returned as-is by Drain().

Background: To avoid leaking the internal implementation of the task
struct, WorkPool.Drain() return a slice of Task interface.

Before this patch, the WorkPool struct would maintain a slice of concret
task struct pointers to be used as return value for the Drain() method.
Since Drain() returns a slice of Task interface, a conversion was
required.

This patch make it so the WorkPool results is a slice of Task interface
instead. That way it can be returned as-is by Drain().

Signed-off-by: Alexandre Perrin <alex@kaworu.ch>
@kaworu kaworu requested a review from rolinh February 11, 2021 11:54
@rolinh rolinh merged commit 2711576 into master Feb 11, 2021
@rolinh rolinh deleted the pr/kaworu/simplify-drain-results branch February 11, 2021 14:33
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