// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java
// @Singleton
// public class Context {
// 	
// 	private final Configuration configuration = new Configuration();
// 	
// 	private Injector injector;
// 	
// 	private final GitUtils gitUtils;
// 	
// 	private final ExecutorService commandRunnerPool;
// 
// 	public Context() {
// 		gitUtils = null;
// 		commandRunnerPool = null;
// 	}
// 	
// 	public Context(GitUtils gitUtils) {
// 		this(gitUtils, null);
// 	}
// 	
// 	@Inject
// 	public Context(GitUtils gitUtils,
// 			@Named("commandRunnerPool") ExecutorService commandRunnerPool) {
// 		this.gitUtils = gitUtils;
// 		this.commandRunnerPool = commandRunnerPool;
// 	}
// 
// 	public Configuration configuration() {
// 		return configuration;
// 	}
// 	
// 	public Injector getInjector() {
// 		return injector;
// 	}
// 	
// 	public ExecutorService getCommandRunnerPool() {
// 		return commandRunnerPool;
// 	}
// 	
// 	public void setInjector(Injector injector) {
// 		this.injector = injector;
// 	}
// 	
// 	public GitUtils getGitUtils() {
// 		return gitUtils;
// 	}
// 
// }
// 
// Path: server/core/src/main/java/org/kercoin/magrit/core/build/BuildResult.java
// public class BuildResult {
// 
// 	private final String sha1;
// 	
// 	private boolean success;
// 
// 	private byte[] log;
// 
// 	private Date startDate;
// 	private Date endDate;
// 
// 	private int exitCode;
// 	
// 	public BuildResult(String sha1) {
// 		this.sha1 = sha1;
// 		success = false;
// 		exitCode = -1;
// 	}
// 
// 	public void setSuccess(boolean success) {
// 		this.success = success;
// 	}
// 	
// 	public void setLog(byte[] log) {
// 		this.log = log;
// 	}
// 	
// 	public void setStartDate(Date startDate) {
// 		this.startDate = startDate;
// 	}
// 	
// 	public void setEndDate(Date endDate) {
// 		this.endDate = endDate;
// 	}
// 	
// 	public long getDuration() {
// 		if (!endDate.after(startDate)) {
// 			throw new IllegalArgumentException("End date is before start date > incoherent!");
// 		}
// 		return endDate.getTime() - startDate.getTime();
// 	}
// 
// 	public boolean isSuccess() {
// 		return success;
// 	}
// 
// 	public byte[] getLog() {
// 		return log;
// 	}
// 
// 	public Date getStartDate() {
// 		return startDate;
// 	}
// 
// 	public Date getEndDate() {
// 		return endDate;
// 	}
// 
// 	public void setExitCode(int exitCode) {
// 		this.exitCode = exitCode;
// 	}
// 	
// 	public int getExitCode() {
// 		return exitCode;
// 	}
// 
// 	public String getCommitSha1() {
// 		return sha1;
// 	}
// 
// }


import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;
import java.util.concurrent.PriorityBlockingQueue;
import java.util.concurrent.RunnableFuture;
import java.util.concurrent.Semaphore;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.kercoin.magrit.core.Context;
import org.kercoin.magrit.core.build.BuildResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.inject.Inject;
import com.google.inject.Singleton;
					} while (!hasAcquired);
					main.writeLock().lockInterruptibly();
					workings.add(k);
					main.writeLock().unlock();
					notifier.justStarted(k);
					return t.call();
				} finally {
					if (hasAcquired) {
						if (!main.writeLock().isHeldByCurrentThread()) {
							main.writeLock().lockInterruptibly();
						}
						tasks.remove(k);
						workings.remove(k);
						main.writeLock().unlock();
						slots.release();
						notifier.justEnded(k);
					}
				}
			} finally {
				lock.unlock();
			}
		}

	}

	private Key nextValid() {
		return new ValidKey(keyId.incrementAndGet());
	}

	@Override
// Path: server/core/src/main/java/org/kercoin/magrit/core/Context.java
// @Singleton
// public class Context {
// 	
// 	private final Configuration configuration = new Configuration();
// 	
// 	private Injector injector;
// 	
// 	private final GitUtils gitUtils;
// 	
// 	private final ExecutorService commandRunnerPool;
// 
// 	public Context() {
// 		gitUtils = null;
// 		commandRunnerPool = null;
// 	}
// 	
// 	public Context(GitUtils gitUtils) {
// 		this(gitUtils, null);
// 	}
// 	
// 	@Inject
// 	public Context(GitUtils gitUtils,
// 			@Named("commandRunnerPool") ExecutorService commandRunnerPool) {
// 		this.gitUtils = gitUtils;
// 		this.commandRunnerPool = commandRunnerPool;
// 	}
// 
// 	public Configuration configuration() {
// 		return configuration;
// 	}
// 	
// 	public Injector getInjector() {
// 		return injector;
// 	}
// 	
// 	public ExecutorService getCommandRunnerPool() {
// 		return commandRunnerPool;
// 	}
// 	
// 	public void setInjector(Injector injector) {
// 		this.injector = injector;
// 	}
// 	
// 	public GitUtils getGitUtils() {
// 		return gitUtils;
// 	}
// 
// }
// 
// Path: server/core/src/main/java/org/kercoin/magrit/core/build/BuildResult.java
// public class BuildResult {
// 
// 	private final String sha1;
// 	
// 	private boolean success;
// 
// 	private byte[] log;
// 
// 	private Date startDate;
// 	private Date endDate;
// 
// 	private int exitCode;
// 	
// 	public BuildResult(String sha1) {
// 		this.sha1 = sha1;
// 		success = false;
// 		exitCode = -1;
// 	}
// 
// 	public void setSuccess(boolean success) {
// 		this.success = success;
// 	}
// 	
// 	public void setLog(byte[] log) {
// 		this.log = log;
// 	}
// 	
// 	public void setStartDate(Date startDate) {
// 		this.startDate = startDate;
// 	}
// 	
// 	public void setEndDate(Date endDate) {
// 		this.endDate = endDate;
// 	}
// 	
// 	public long getDuration() {
// 		if (!endDate.after(startDate)) {
// 			throw new IllegalArgumentException("End date is before start date > incoherent!");
// 		}
// 		return endDate.getTime() - startDate.getTime();
// 	}
// 
// 	public boolean isSuccess() {
// 		return success;
// 	}
// 
// 	public byte[] getLog() {
// 		return log;
// 	}
// 
// 	public Date getStartDate() {
// 		return startDate;
// 	}
// 
// 	public Date getEndDate() {
// 		return endDate;
// 	}
// 
// 	public void setExitCode(int exitCode) {
// 		this.exitCode = exitCode;
// 	}
// 	
// 	public int getExitCode() {
// 		return exitCode;
// 	}
// 
// 	public String getCommitSha1() {
// 		return sha1;
// 	}
// 
// }


// Path: server/core/src/main/java/org/kercoin/magrit/core/build/pipeline/PipelineImpl.java
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;
import java.util.concurrent.PriorityBlockingQueue;
import java.util.concurrent.RunnableFuture;
import java.util.concurrent.Semaphore;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.kercoin.magrit.core.Context;
import org.kercoin.magrit.core.build.BuildResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.inject.Inject;
import com.google.inject.Singleton;

					} while (!hasAcquired);
					main.writeLock().lockInterruptibly();
					workings.add(k);
					main.writeLock().unlock();
					notifier.justStarted(k);
					return t.call();
				} finally {
					if (hasAcquired) {
						if (!main.writeLock().isHeldByCurrentThread()) {
							main.writeLock().lockInterruptibly();
						}
						tasks.remove(k);
						workings.remove(k);
						main.writeLock().unlock();
						slots.release();
						notifier.justEnded(k);
					}
				}
			} finally {
				lock.unlock();
			}
		}

	}

	private Key nextValid() {
		return new ValidKey(keyId.incrementAndGet());
	}

	@Override
	public Key submit(Task<BuildResult> task) {