Stream type enhancements: finalization

オープン
#3,081 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
haskell
領域
backend

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Haskell
スター
926
フォーク
71
平均マージ
6時間 49分
マージ済み PR(30日)
3

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

composewell/streamly のほかの issue

composewell/streamly の issue をすべて見る

似ている issue

Haskell の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。