Stream type enhancements: finalization

Aperta
#3,081 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
haskell
Ambito
backend

Direzione di ricerca

Read the stream type definitions and the existing finalization support in the fold type, which the issue identifies as a precedent. Trace how take, terminating folds, and parRepeatM behave when a stream is not fully consumed. Done means defining and integrating stream finalization so early termination cleans up held resources, with tests covering those cases.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

api:breaking aspect:api aspect:streams priority:high

We use the bracket combinator to allocate a resource and use it inside the stream. When the stream stops or if an exception occurs the resource if freed automatically. However, if the stream is not fully consumed (e.g. if a fold terminates before the stream stops) then there is no way to cleanup any resources held by the stream other than GC. The only ways to do that is to either (1) drain the stream fully, or (2) let the GC clean it up.

Not sure if this is an important requirement but it can be solved by having a finalization function in the stream type just like we added one in the fold type. This will complicate all stream definitions though, just like it did in folds.

A stream would remain unconsumed on when take is used on it or a terminating fold is used on it which terminates before the stream terminates. If we use parRepeatM to generate a stream and then take just 1 element, the worker threads may still continue working until the stream is garbage collected, this could be problematic.

See also #585 for another stream type enhancement use case.

Lingua principale
Haskell
Stelle
926
Fork
71
Merge medio
6h 49m
PR unite (30g)
3

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di composewell/streamly

Tutte le issue di composewell/streamly

Issue simili

Altre issue su Haskell

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.