class SimpleSlot extends Slot implements LogicalSlot {

	@Override
	public CompletableFuture<?> releaseSlot(@Nullable Throwable cause) {
		if (!isCanceled()) {
			final CompletableFuture<?> terminationFuture;

			if (payload != null) {
				// trigger the failure of the slot payload
				payload.fail(cause != null ? cause : new FlinkException("TaskManager was lost/killed: " + getTaskManagerLocation()));

				// wait for the termination of the payload before releasing the slot
				terminationFuture = payload.getTerminalStateFuture();
			} else {
				terminationFuture = CompletableFuture.completedFuture(null);
			}

			terminationFuture.whenComplete(
				(Object ignored, Throwable throwable) -> {
					// release directly (if we are directly allocated),
					// otherwise release through the parent shared slot
					if (getParent() == null) {
						// we have to give back the slot to the owning instance
						if (markCancelled()) {
							getOwner().returnAllocatedSlot(this).whenComplete(
								(value, t) -> {
									if (t != null) {
										releaseFuture.completeExceptionally(t);
									} else {
										releaseFuture.complete(null);
									}
								});
						}
					} else {
						// we have to ask our parent to dispose us
						getParent().releaseChild(this);

						releaseFuture.complete(null);
					}
				});
		}

		return releaseFuture;
	}

	public  SimpleSlot(
		SlotOwner owner, TaskManagerLocation location, int slotNumber,
		TaskManagerGateway taskManagerGateway);
	public  SimpleSlot(
			SlotOwner owner,
			TaskManagerLocation location,
			int slotNumber,
			TaskManagerGateway taskManagerGateway,
			@Nullable SharedSlot parent,
			@Nullable AbstractID groupID);
	public  SimpleSlot(SlotContext slotContext, SlotOwner owner, int slotNumber);
	public  SimpleSlot(SharedSlot parent, SlotOwner owner, int slotNumber, AbstractID groupID);
	private  SimpleSlot(
			SlotContext slotContext,
			SlotOwner owner,
			int slotNumber,
			@Nullable SharedSlot parent,
			@Nullable AbstractID groupID);

}