void (@NotNull final PacketProcessor packetProcessor, final DeferredActionsQueue queue) { myFulfilledWorkGate = new DeferredActionsQueue() { //todo make it all later @Override public void addLast(final Runnable runnable) { scheduleTask(queue, runnable); } @Override public void setDispactchListener(final DispatchListener listener) { queue.setDispactchListener(listener); } }; myEventsDispatcher = new OutputPacketProcessor() { @Override public void processPacket(final String packet) { myFulfilledWorkGate.addLast(() -> packetProcessor.processPacket(packet)); } @Override public void processOutput(final Printable printable) { LOG.assertTrue(packetProcessor instanceof OutputPacketProcessor); myFulfilledWorkGate.addLast(() -> ((OutputPacketProcessor)packetProcessor).processOutput(printable)); } }; myStream.setEventsDispatcher(myEventsDispatcher); }