Skip to content

Commit

Permalink
Try self-cancelling before running to deadlock
Browse files Browse the repository at this point in the history
Align the implementation with Spawn docs.
Close typelevel#4093.
  • Loading branch information
lenguyenthanh committed Sep 8, 2024
1 parent dab9d23 commit 7d7f60c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions kernel/shared/src/main/scala/cats/effect/kernel/Fiber.scala
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@ trait Fiber[F[_], E, A] extends Serializable {
*
* If the fiber completes with [[Outcome.Succeeded]], the successful value is returned. If the
* fiber completes with [[Outcome.Errored]], the error is raised. If the fiber completes with
* [[Outcome.Canceled]], the caller is indefinitely suspended without termination.
* [[Outcome.Canceled]], attempt to self-cancel, and if the self-cancelation fails, the caller
* is indefinitely suspended without termination.
*/
def joinWithNever(implicit F: GenSpawn[F, E]): F[A] =
joinWith(F.never)
joinWith(F.canceled >> F.never)

/**
* Awaits the completion of the bound fiber and returns its result once it completes.
Expand Down

0 comments on commit 7d7f60c

Please sign in to comment.