microsoft / microsoft/stackfuture

Add a way to resize StackFutures

Offen
#6 5 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
Rust
Sterne
314
Forks
17
Ø Merge
11 Std. 50 Min.
Gemergte PRs (30 T.)
1

Beschreibung

It'd be helpful to have a way to shrink (or less commonly, grow) a StackFuture. For example, sometimes you have an object that implements a trait and needs to forward calls to another object that implements the same trait. Right now that's impossible with StackFuture without boxing the child future because otherwise you'd have to have a future contain a future that's the same size as itself. That said, there will usually be some extra space so we might be able to dynamically shrink a StackFuture.

The signature would probably be something like:

fn resize<const NEW_SIZE: usize>(self) -> Result<StackFuture<T, NEW_SIZE>, Self>;

Then using this would look something like:

impl Foo for MyObject {
    fn bar(&self) -> StackFuture<(), 1000> {
        match self.sub_object.bar().resize::<{500}>() {
            Ok(f) => f.await,
            Err(original) => Box::pin(original).await,
        }
    }
}

The idea here is we'd try to fit the future into a smaller container, but if it doesn't fit then the resize returns the original future and we can either decide to pay the allocation cost (as we did in this example) or give up.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Lies zunächst die StackFuture-Implementierung und die vorhandenen Tests im Repository, und verfolge anschließend, wie ihre Speichergröße und Ownership dargestellt werden. Bewerte die vorgeschlagene resize-API einschließlich der Erfolgs- und Fehlerpfade des ursprünglichen Futures; als erledigt gilt, wenn ein kleineres oder größeres StackFuture sicher versucht werden kann, ohne es zu boxen, sofern das Resizing nicht fehlschlägt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
rust
Bereich
backend
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.