Package org.drasyl.handler.arq.gobackn
Class SimpleWindow
java.lang.Object
org.drasyl.handler.arq.gobackn.SimpleWindow
- All Implemented Interfaces:
Window
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.drasyl.handler.arq.gobackn.Window
Window.Frame
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
add
(GoBackNArqData msg, io.netty.channel.ChannelPromise promise) Adds the given msg to the window, if there is enough capacity.int
getQueue()
io.netty.channel.ChannelPromise
remove()
Removes the oldest message from the window.void
removeAndFailAll
(Throwable cause) Clears the window and let's fail all write promises.int
size()
-
Constructor Details
-
SimpleWindow
public SimpleWindow(int capacity) Creates a new simple window.- Parameters:
capacity
- the window size/capacity
-
-
Method Details
-
add
Description copied from interface:Window
Adds the given msg to the window, if there is enough capacity. -
remove
public io.netty.channel.ChannelPromise remove()Description copied from interface:Window
Removes the oldest message from the window. -
getQueue
-
size
public int size() -
getFreeSpace
public int getFreeSpace()- Specified by:
getFreeSpace
in interfaceWindow
- Returns:
- the free space of the window
-
removeAndFailAll
Description copied from interface:Window
Clears the window and let's fail all write promises.- Specified by:
removeAndFailAll
in interfaceWindow
- Parameters:
cause
- the cause of the failure
-