PollingSystem

cats.effect.unsafe.PollingSystem
abstract class PollingSystem

Represents a stateful system for managing and interacting with a polling system. Polling systems are typically used in scenarios such as handling multiplexed blocking I/O or other event-driven systems, where one needs to repeatedly check (or "poll") some condition or state, blocking up to some timeout until it is ready.

This class abstracts the general components and actions of a polling system, such as:

  • The user-facing interface (API) which interacts with the outside world

  • The thread-local data structure used for polling, which keeps track of the internal state of the system and its events

  • The lifecycle management methods, such as creating and closing the polling system and its components

  • The runtime interaction methods, such as polling events and interrupting the process

Attributes

Source
PollingSystem.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object SleepSystem.type

Members list

Type members

Types

type Api <: AnyRef

The user-facing interface.

The user-facing interface.

Attributes

Source
PollingSystem.scala
type Poller <: AnyRef

The thread-local data structure used for polling.

The thread-local data structure used for polling.

Attributes

Source
PollingSystem.scala

Value members

Abstract methods

def close(): Unit

Closes the polling system.

Closes the polling system.

Attributes

Source
PollingSystem.scala
def closePoller(poller: Poller): Unit

Closes a specific poller.

Closes a specific poller.

Value parameters

poller

the poller to be closed.

Attributes

Source
PollingSystem.scala
def interrupt(targetThread: Thread, targetPoller: Poller): Unit

Interrupts a specific target poller running on a specific target thread.

Interrupts a specific target poller running on a specific target thread.

Value parameters

targetPoller

is the poller to be interrupted.

targetThread

is the thread where the target poller is running.

Attributes

Source
PollingSystem.scala
def makeApi(access: (Poller => Unit) => Unit): Api

Creates a new instance of the user-facing interface.

Creates a new instance of the user-facing interface.

Value parameters

access

callback to obtain a thread-local Poller.

Attributes

Returns

an instance of the user-facing interface Api.

Source
PollingSystem.scala

Creates a new instance of the thread-local data structure used for polling.

Creates a new instance of the thread-local data structure used for polling.

Attributes

Returns

an instance of the poller Poller.

Source
PollingSystem.scala
def needsPoll(poller: Poller): Boolean

Attributes

Returns

whether poll should be called again (i.e., there are more events to be polled)

Source
PollingSystem.scala
def poll(poller: Poller, nanos: Long, reportFailure: Throwable => Unit): Boolean

Value parameters

nanos

the maximum duration for which to block, where nanos == -1 indicates to block indefinitely.

poller

the thread-local Poller used to poll events.

reportFailure

callback that handles any failures that occur during polling.

Attributes

Returns

whether any events were polled. e.g. if the method returned due to timeout, this should be false.

Source
PollingSystem.scala