Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
adamw committed Oct 31, 2023
1 parent 218162c commit 8f006a5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions core/src/main/scala/ox/channels2/Channel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ class Channel[T]:
result

def await(onInterrupt: () => Unit): E =
var firstIteration = true
var spinIterations = 1000
while data.get() == null do
if firstIteration then
Thread.`yield`()
firstIteration = false
if spinIterations > 0 then
Thread.onSpinWait()
spinIterations -= 1
else LockSupport.park()

if Thread.interrupted() then
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/ox/channels2/perf/tests.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ox.channels2.perf

@main def run(): Unit =
for (i <- 1 to 3) {
for (i <- 1 to 10) {
println(s"Run $i")
usingOx()
// passingValues()
Expand Down

0 comments on commit 8f006a5

Please sign in to comment.