typelevel / typelevel/cats-effect

Fork-with-finalizer method on `GenSpawn`

Open
#4,517 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

:mushroom: enhancement
Dominant language
Scala
Stars
2.2k
Forks
576
Avg merge
2d 11h
Merged PRs (30d)
18

Description

(Based on this comment by @TomasMikula; I'm opening a new issue, because approximately nobody reads closed issues.)

The idea is to have a new method on GenSpawn like this (name TBD):

def forkWithFinalizer[A](fa: F[A], fin: F[Unit]): F[Fiber[F, A]]

It would be different from start in that if this method returned a fiber, then fin would be guaranteed to be executed (except of course if fa hangs). There is no such gurarantee with start.

A new method on GenSpawn would require a default implementation. A possibility is in #4500.

Open questions:

  • Do we actually want something like this on the public API?
  • Are we okay with the default implementation? (I think it works, but I've been wrong before.)
  • What to name the method?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the linked comment in issue #4488, then review GenSpawn and the possible default implementation discussed in #4500. The issue leaves the method name, public API decision, and default-implementation behavior open, so done would require resolving those design questions before implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.