Class SelectorThread

java.lang.Object
java.lang.Thread
com.sshtools.synergy.nio.SelectorThread
All Implemented Interfaces:
Runnable

public class SelectorThread extends Thread
Provides management of a single selector.
  • Constructor Details

    • SelectorThread

      public SelectorThread(SelectorThreadPool pool, SelectorThreadImpl impl, boolean isPermanent, int maximumNumOfChannels, int id, int idleServicePeriod, int inactivePeriodsPerIdleEvent, SelectorProvider selectorProvider) throws IOException
      Construct a new selector thread.
      Parameters:
      pool - SelectorThreadPool
      impl - SelectorThreadImpl
      isPermanent - boolean
      maximumNumOfChannels - int
      id - int
      idleServicePeriod - int
      inactivePeriodsPerIdleEvent - int
      selectorProvider - SelectorProvider
      Throws:
      IOException
  • Method Details

    • register

      public boolean register(SelectableChannel sc, int ops, Object attachment, boolean wakeUp) throws ClosedChannelException
      Register a channel with the selector.
      Parameters:
      sc - SelectableChannel
      ops - int
      attachment - Object
      wakeUp - boolean
      Returns:
      boolean
      Throws:
      ClosedChannelException
    • closeAllChannels

      public void closeAllChannels()
    • addSelectorOperation

      public void addSelectorOperation(Runnable r)
      Add an operation to the selector.
      Parameters:
      r - Runnable
    • wakeup

      public void wakeup()
      Wakeup the selector.
    • getThreadLoad

      public int getThreadLoad()
      Get the current thread load.
      Returns:
      int
    • isPermanent

      public boolean isPermanent()
      Is this a permanent thread?
      Returns:
      boolean
    • flagShutdown

      public void flagShutdown()
      Shutdown the thread.
    • shutdown

      public void shutdown()
    • getSelectorId

      public int getSelectorId()
      Get the id of this selector thread.
      Returns:
      int
    • getMaximumLoad

      public int getMaximumLoad()
      Get the maximum number of channels that this thread can service.
      Returns:
      int
    • run

      public void run()
      The threads main.
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Thread
    • cancelKey

      public void cancelKey(SelectionKey key)