class SpilledSubpartitionView implements ResultSubpartitionView, NotificationListener {

	@Override
	public void releaseAllResources() throws IOException {
		if (isReleased.compareAndSet(false, true)) {
			// TODO This can block until all buffers are written out to
			// disk if a spill is in-progress before deleting the file.
			// It is possibly called from the Netty event loop threads,
			// which can bring down the network.
			spillWriter.closeAndDelete();

			synchronized (this) {
				fileReader.close();
				if (nextBuffer != null) {
					nextBuffer.recycleBuffer();
					nextBuffer = null;
				}
			}

			bufferPool.destroy();
		}
	}

	  SpilledSubpartitionView(
		SpillableSubpartition parent,
		int memorySegmentSize,
		BufferFileWriter spillWriter,
		long numberOfSpilledBuffers,
		BufferAvailabilityListener availabilityListener);

}