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 context to the task function signature #12

Merged
merged 1 commit into from
Feb 11, 2021
Merged

Conversation

rolinh
Copy link
Member

@rolinh rolinh commented Feb 11, 2021

There are use-cases where the caller does not care about the results of
tasks processing and thus never calls the Drain method. This is
typically the case for tasks that are never expected to return unless a
context is cancelled. To accommodate for this use-case, add a context as
a parameter to the task function.

As tasks are now allowed to run forever unless the context is cancelled,
ensure that calling the Close method cancels the tasks context to
properly tear down all workers. It is the responsibility of the library
user to ensure submitted tasks respect the context.

There are use-cases where the caller does not care about the results of
tasks processing and thus never calls the Drain method. This is
typically the case for tasks that are never expected to return unless a
context is cancelled. To accommodate for this use-case, add a context as
a parameter to the task function.

As tasks are now allowed to run forever unless the context is cancelled,
ensure that calling the Close method cancels the tasks context to
properly tear down all workers. It is the responsibility of the library
user to ensure submitted tasks respect the context.

Signed-off-by: Robin Hahling <robin.hahling@gw-computing.net>
@rolinh rolinh requested a review from kaworu February 11, 2021 14:31
Copy link
Member

@kaworu kaworu left a comment

Choose a reason for hiding this comment

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

LGTM thanks!

@kaworu kaworu merged commit 2d5f1c2 into master Feb 11, 2021
@kaworu kaworu deleted the pr/rolinh/context branch February 11, 2021 17:01
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