Skip to content

Commit

Permalink
Use inline parameters instead of by-name methods
Browse files Browse the repository at this point in the history
  • Loading branch information
adamw committed Mar 20, 2024
1 parent a02f419 commit 3956b95
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions core/src/main/scala/ox/control.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ package ox

import java.util.concurrent.locks.LockSupport

inline def forever(f: => Unit): Nothing =
inline def forever(inline f: Unit): Nothing =
while true do f
throw new RuntimeException("can't get here")

/** Repeat evaluating `f` while it evaluates to `true`. */
inline def repeatWhile(f: => Boolean): Unit =
inline def repeatWhile(inline f: Boolean): Unit =
var loop = true
while loop do loop = f

/** Repeat evaluating `f` until it evaluates to `true`. */
inline def repeatUntil(f: => Boolean): Unit =
inline def repeatUntil(inline f: Boolean): Unit =
var loop = true
while loop do loop = !f

inline def uninterruptible[T](f: => T): T =
inline def uninterruptible[T](inline f: T): T =
scoped {
val t = fork(f)

Expand Down

0 comments on commit 3956b95

Please sign in to comment.