All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.emc.mongoose.common.concurrent.SvcTaskBase Maven / Gradle / Ivy

The newest version!
package com.emc.mongoose.common.concurrent;

import java.io.IOException;
import java.util.List;

/**
 Created by andrey on 19.04.17.
 */
public abstract class SvcTaskBase
implements SvcTask {

	private final List svcTasks;

	private volatile boolean isClosedFlag = false;

	protected SvcTaskBase(final List svcTasks) {
		this.svcTasks = svcTasks;
	}

	@Override
	public final void close()
	throws IOException {
		isClosedFlag = true;
		svcTasks.remove(this);
		doClose();
	}

	@Override
	public void run() {
		if(!isClosedFlag) {
			invoke();
		}
	}

	@Override
	public final boolean isClosed() {
		return isClosedFlag;
	}

	protected abstract void invoke();

	protected abstract void doClose()
	throws IOException;
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy