package com.eactive.eai.common.worker;

public class Future {
	private Object value;
	private Slot slot; // shared with some worker

	public Future() {
		this.slot = new Slot();
	}

	public Slot getSlot() {
		return this.slot;
	}

	public Object value() {
		synchronized (slot) { // avoid race conditions!
			if (value == null)
				value = slot.get();
		}
		return value;
	}

	public Object value(long timeout) {
		synchronized (slot) { // avoid race conditions!
			if (value == null)
				value = slot.get(timeout);
		}
		return value;
	}
}
