Class SimpleWindow

java.lang.Object
org.drasyl.handler.arq.gobackn.SimpleWindow
All Implemented Interfaces:
Window

public class SimpleWindow extends Object implements Window
  • Constructor Details

    • SimpleWindow

      public SimpleWindow(int capacity)
      Creates a new simple window.
      Parameters:
      capacity - the window size/capacity
  • Method Details

    • add

      public boolean add(GoBackNArqData msg, io.netty.channel.ChannelPromise promise)
      Description copied from interface: Window
      Adds the given msg to the window, if there is enough capacity.
      Specified by:
      add in interface Window
      Parameters:
      msg - the message to add
      promise - the write promise
      Returns:
      true, if the message could be added, false if the window has no capacity
    • remove

      public io.netty.channel.ChannelPromise remove()
      Description copied from interface: Window
      Removes the oldest message from the window.
      Specified by:
      remove in interface Window
      Returns:
      the write promise of the oldest message
    • getQueue

      public List<Window.Frame> getQueue()
      Specified by:
      getQueue in interface Window
      Returns:
      the original unacknowledged message queue
    • size

      public int size()
      Specified by:
      size in interface Window
      Returns:
      the size of the window
    • getFreeSpace

      public int getFreeSpace()
      Specified by:
      getFreeSpace in interface Window
      Returns:
      the free space of the window
    • removeAndFailAll

      public void removeAndFailAll(Throwable cause)
      Description copied from interface: Window
      Clears the window and let's fail all write promises.
      Specified by:
      removeAndFailAll in interface Window
      Parameters:
      cause - the cause of the failure