package com.hammurapi.common;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * LocalJoiner uses java.util.concurrent.locks.ReentrantLock to protect simultaneous access
 * to input collectors. 
 * @author Pavel Vlasov
 *
 * @param <T>
 * @param <C>
 * @param <R>
 */
public abstract class LocalJoiner<T, C, R> extends Joiner<T, C, R> {
	
	Lock lock = new ReentrantLock();

	protected LocalJoiner(
			Collector<T>[] inputCollectors, 
			Class<T> inputType,
			boolean outerJoin) {
		super(inputCollectors, inputType, outerJoin);
	}
	
	@Override
	protected void startJoin() {
		lock.lock();		
	}
	
	@Override
	protected void endJoin() {
		lock.unlock();		
	}

}
