class OperatorEventValve {

	public CompletableFuture<Acknowledge> sendEvent(SerializedValue<OperatorEvent> event, int subtask) {
		synchronized (lock) {
			if (!shut) {
				return eventSender.apply(event, subtask);
			}

			final List<BlockedEvent> eventsForTask = blockedEvents.computeIfAbsent(subtask, (key) -> new ArrayList<>());
			final CompletableFuture<Acknowledge> future = new CompletableFuture<>();
			eventsForTask.add(new BlockedEvent(event, subtask, future));
			return future;
		}
	}

	public  OperatorEventValve(BiFunction<SerializedValue<OperatorEvent>, Integer, CompletableFuture<Acknowledge>> eventSender);

}