cats-effect icon indicating copy to clipboard operation
cats-effect copied to clipboard

Add `Lock` to std

Open armanbilge opened this issue 2 years ago • 6 comments
trafficstars

Spinning out of https://github.com/typelevel/cats-effect/pull/3480#discussion_r1125597170.

The API would look something like:

abstract class Lock[F[_]] {
  def shared: Resource[F, Unit]
  def exclusive: Resource[F, Unit]
}

armanbilge avatar Apr 15 '23 00:04 armanbilge

https://github.com/davenverse/lock - Available as some prior art.

ChristopherDavenport avatar Apr 15 '23 01:04 ChristopherDavenport

…with the caveat that we can only implement reentrancy for IO, not for general effect types, since reentrancy requires some form of fiber identity (which we can access using IOLocal).

djspiewak avatar Apr 15 '23 14:04 djspiewak

Hi, I would like to help on this issue !

kevchuang avatar Apr 17 '23 12:04 kevchuang