Skip to content

Commit

Permalink
Cache default mask
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniojimeneznieto committed Aug 25, 2023
1 parent bea40a8 commit 42c6b91
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions uring/src/main/scala/fs2/io/uring/Uring.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ import scala.scalanative.unsafe.Ptr
private[uring] final class Uring[F[_]](ring: UringExecutorScheduler)(implicit F: Async[F]) {

private[this] val noopRelease: Int => F[Unit] = _ => F.unit
private[this] val noopMask: Int => Boolean = _ => false

def call(prep: Ptr[io_uring_sqe] => Unit, mask: Int => Boolean = _ => false): F[Int] =
def call(prep: Ptr[io_uring_sqe] => Unit, mask: Int => Boolean = noopMask): F[Int] =
exec(prep, mask)(noopRelease)

def bracket(prep: Ptr[io_uring_sqe] => Unit, mask: Int => Boolean = _ => false)(release: Int => F[Unit]): Resource[F, Int] =
def bracket(prep: Ptr[io_uring_sqe] => Unit, mask: Int => Boolean = noopMask)(release: Int => F[Unit]): Resource[F, Int] =
Resource.makeFull[F, Int](poll => poll(exec(prep, mask)(release(_))))(release(_))

private def exec(prep: Ptr[io_uring_sqe] => Unit, mask: Int => Boolean)(release: Int => F[Unit]): F[Int] =
Expand Down

0 comments on commit 42c6b91

Please sign in to comment.