Class Reactor

java.lang.Object
com.codename1.backend.Reactor

public final class Reactor extends Object

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.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Deliver an event for this descriptor ONCE and then disarm it, until modify(int, int) re-arms it.
    static final int
     
    static final int
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(int fd, int events)
     
    int
    await(int[] readyFds, int timeoutMillis)
    Blocks until something is ready, then fills readyFds and returns how many.
    void
     
    static Reactor
     
    void
    modify(int fd, int events)
     
    void
    remove(int fd)
     

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • READ

      public static final int READ
      See Also:
    • WRITE

      public static final int WRITE
      See Also:
    • ONESHOT

      public static final int ONESHOT

      Deliver an event for this descriptor ONCE and then disarm it, until modify(int, int) 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.

      See Also:
  • Method Details

    • create

      public static Reactor create() throws IOException
      Throws:
      IOException
    • add

      public void add(int fd, int events) throws IOException
      Throws:
      IOException
    • modify

      public void modify(int fd, int events) throws IOException
      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.
      Throws:
      IOException
    • close

      public void close()