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 variant of LocalPool with bound lifetime #2846

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

haroldbruintjes
Copy link

This modifies LocalPool to accept a generic lifetime parameter, and renames it to BoundLocalPool parameter, with LocalPool now being an alias for BoundLocalPool<'static>. Associated types (Incoming and LocalSpawner) get the same treatment where applicable. Add additional BoundLocalSpawn and BoundLocalSpawnExt traits that extend the unbound variants with functions spawning bound-lifetime tasks.

The purpose of this is to enable the use of an executor that does not require the futures assigned to it to exist any longer than it does. Existing code should of course still just work as it is.

Somewhat tangentially related, the implementations for the various spawner traits have been consolidated to just require Deref, but that need not be part of the same change and does break compatibility. I left it in as a suggestion, but I suspect that should be reverted :).

@haroldbruintjes haroldbruintjes force-pushed the boundlocalpool branch 2 times, most recently from 8a19658 to 81bcdac Compare March 28, 2024 08:58
Adds derivatives of LocalPool and BoundLocalSpawner with a generic
lifetime parameter that replaces the previously used 'static, and
aliases both types with a 'static parameter to the originals.

Add a BoundLocalSpawn trait in a similar fashion. At the same time
simplify the implementation of Spawn, LocalSpawn and BoundLocalSpawn to
just work on any type implementing Deref to a type implementing a spawn
trait.
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.

None yet

1 participant