Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.

public final class Reactor

  1. Object
  2. Reactor

Readiness notification over epoll (Linux) or kqueue (macOS/BSD).

Level-triggered: the poller hands a ready descriptor to a worker and forgets about it until the worker gives it back. Edge-triggered would require draining every descriptor to EAGAIN on each wake-up, which is the opposite of that.

Fields

public static final int READ = 1
public static final int WRITE = 2
public static final int ONESHOT = 4Deliver an event for this descriptor ONCE and then disarm it, until modify re-arms it.

Methods

public static Reactor create() throws IOException
public void add(int fd, int events) throws IOException
public void modify(int fd, int events) throws IOException
public void remove(int fd)
public int await(int[] readyFds, int timeoutMillis) throws IOExceptionBlocks until something is ready, then fills readyFds and returns how many.
public void close()

Inherited methods

Field details

READ

public static final int READ = 1

WRITE

public static final int WRITE = 2

ONESHOT

public static final int ONESHOT = 4

Deliver an event for this descriptor ONCE and then disarm it, until modify re-arms it.

This is what lets the worker threads poll the same set directly rather than a reactor thread dispatching to them: the kernel guarantees exactly one waiter is handed a given descriptor, so two workers cannot land on one connection. Without it a level-triggered set reports the same descriptor ready to every waiter at once.

Method details

create

public static Reactor create() throws IOException

add

public void add(int fd, int events) throws IOException

modify

public void modify(int fd, int events) throws IOException

remove

public void remove(int fd)

await

public int await(int[] readyFds, int timeoutMillis) throws IOException
Blocks until something is ready, then fills readyFds and returns how many. A timeout below zero waits forever.

close

public void close()