Current system is prone to high memory allocation. I believe it's because of allocation of Consumer to pass packets generated from current filter to next filter for every packet emitted. Combine that with my 240Hz tablet and it would fill up the memory, causing GC to trigger more frequent.
The new Packet Filter interface will be something like this:
public interface PacketFilter {
public void initialize(FilterHost host, Consumer<Packet> pusher);
public void onPacket(Packet packet);
public Codec<? extends PacketFilter> getCodec();
}
initialize(): Called when initializing filters chain, which is when all filters are loaded or the filters ordering changed.
onPacket(): Called when a packet is received from either the input device or from previous filter in the filters chain. This will always be called in input thread.
getCodec(): Get DFU codec for filter's configuration.
Additionally, a new AbstractPacketFilter will be added to include additional methods:
public interface IAbstractPacketFilter extends PacketFilter {
@Override
default void initialize(FilterHost host, Consumer<Packet> pusher) {} // implemented in abstract class
public void push(Packet packet);
public FilterHost getHost();
}
push(): Push the packet to next filter in the chain or to application if there is no other downstream filters.
getHost(): Get the filters host, which allows filters to get information about the current tablet and application's info (window size, selected brush, etc.).
Current system is prone to high memory allocation. I believe it's because of allocation of
Consumer
to pass packets generated from current filter to next filter for every packet emitted. Combine that with my 240Hz tablet and it would fill up the memory, causing GC to trigger more frequent.The new Packet Filter interface will be something like this:
initialize()
: Called when initializing filters chain, which is when all filters are loaded or the filters ordering changed.onPacket()
: Called when a packet is received from either the input device or from previous filter in the filters chain. This will always be called in input thread.getCodec()
: Get DFU codec for filter's configuration.Additionally, a new
AbstractPacketFilter
will be added to include additional methods:push()
: Push the packet to next filter in the chain or to application if there is no other downstream filters.getHost()
: Get the filters host, which allows filters to get information about the current tablet and application's info (window size, selected brush, etc.).