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

Troves spawn cleanup functions (solution for #209) #210

Merged
merged 1 commit into from
Dec 9, 2024

Conversation

ambergamefam
Copy link
Contributor

@ambergamefam ambergamefam commented Dec 9, 2024

This PR proposes a change where adding a yielding or erroring function to a trove will not block other tasks added to that trove from cleaning up.

See #209 for a further description of this problem.

This example highlights why this change is useful needed:

trove:Add(function()
    print("Task #1")
end)
trove:Add(function()
    print("Task #2 started")
    task.wait(1)
    print("Task #2 completed (1 second later)")
end)
trove:Add(function()
    print("Task #3")
end)

Previously, the output would block any tasks added after Task #2 from cleaning up until task #2 completes:

> Task #1
> Task #2 started
> Task #2 completed (1 second later)
> Task #3

With this change, Task #2 does not block the trove from cleaning up, which saves is more intuitive to the library user, and saves on debugging time to understand the conventional rule of why you can't yield on Task #2:

> Task #1
> Task #2
> Task #3
> Task #2 completed (1 second later)

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.

Adding a yielding or erroring function to a Trove blocks every other task added to the Trove
2 participants