Skip to content

Commit

Permalink
Remove broken SelectorSystem#steal impl
Browse files Browse the repository at this point in the history
  • Loading branch information
armanbilge committed Aug 6, 2024
1 parent cc14b5e commit 3869424
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 90 deletions.
58 changes: 2 additions & 56 deletions core/jvm/src/main/scala/cats/effect/unsafe/SelectorSystem.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ package unsafe

import scala.util.control.NonFatal

import java.nio.channels.{ClosedSelectorException, SelectableChannel}
import java.nio.channels.SelectableChannel
import java.nio.channels.spi.{AbstractSelector, SelectorProvider}
import java.util.ConcurrentModificationException

import SelectorSystem._

Expand Down Expand Up @@ -99,60 +98,7 @@ final class SelectorSystem private (provider: SelectorProvider) extends PollingS
} else false
}

def steal(poller: Poller, reportFailure: Throwable => Unit): Boolean = {
val selector = poller.selector

val keys =
try {
if (selector.isOpen()) {
selector.selectNow()
selector.selectedKeys()
} else return false
} catch { // selector closed concurrently
case _: ClosedSelectorException => return false
}

var polled = false
val ready = keys.iterator()

try {
while (ready.hasNext()) {
val key = ready.next()

var readyOps = 0
var error: Throwable = null
try {
readyOps = key.readyOps()
} catch {
case ex if NonFatal(ex) =>
error = ex
readyOps = -1 // notify all waiters
}

val value = if (error ne null) Left(error) else Right(readyOps)

var node = key.attachment().asInstanceOf[CallbackNode]
while (node ne null) {
val next = node.next

if ((node.interest & readyOps) != 0) { // execute callback
val cb = node.callback
if (cb != null) {
cb(value)
polled = true
}
}

node = next
}
}
} catch {
case _: ConcurrentModificationException =>
// owner thread concurrently processing selected keys, so suppress and exit loop
}

polled
}
def steal(poller: Poller, reportFailure: Throwable => Unit): Boolean = false

def needsPoll(poller: Poller): Boolean =
!poller.selector.keys().isEmpty()
Expand Down

This file was deleted.

0 comments on commit 3869424

Please sign in to comment.