<commit_before>package ch.usi.dag.dislreserver.msg.analyze.mtdispatch;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

import ch.usi.dag.dislreserver.exception.DiSLREServerFatalException;

/**
 * Manages executors 
 */
class ATEManager {

	protected final Map<Long, AnalysisTaskExecutor> liveExecutors =
			new HashMap<Long, AnalysisTaskExecutor>();
	
	protected final BlockingQueue<AnalysisTaskExecutor> endingExecutors =
			new LinkedBlockingQueue<AnalysisTaskExecutor>();

	/**
	 * Retrieves executor. Creates new one if it does not exists. 
	 */
	public AnalysisTaskExecutor getExecutor(long id) {
		
		AnalysisTaskExecutor ate = liveExecutors.get(id);
		
		// create new executor
		if(ate == null) {
			
			ate = new AnalysisTaskExecutor(this);
			liveExecutors.put(id, ate);
		}
		
		return ate;
	}
	
	/**
	 * Retrieves all live executors 
	 */
	public Collection<AnalysisTaskExecutor> getAllLiveExecutors() {
		
		// return copy
		return new ArrayList<AnalysisTaskExecutor>(liveExecutors.values());
	}
	
	/**
	 * Moves executor from live queue to the ending queue
	 */<commit_msg>Small perf. improvement to ATEManager<commit_after>package ch.usi.dag.dislreserver.msg.analyze.mtdispatch;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

import ch.usi.dag.dislreserver.exception.DiSLREServerFatalException;

/**
 * Manages executors 
 */
class ATEManager {

	protected final Map<Long, AnalysisTaskExecutor> liveExecutors =
			new HashMap<Long, AnalysisTaskExecutor>();
	
	protected final BlockingQueue<AnalysisTaskExecutor> endingExecutors =
			new LinkedBlockingQueue<AnalysisTaskExecutor>();

	/**
	 * Retrieves executor. Creates new one if it does not exists. 
	 */
	public AnalysisTaskExecutor getExecutor(long id) {
		
		AnalysisTaskExecutor ate = liveExecutors.get(id);
		
		// create new executor
		if(ate == null) {
			
			ate = new AnalysisTaskExecutor(this);
			liveExecutors.put(id, ate);
		}
		
		return ate;
	}
	
	/**
	 * Retrieves all live executors 
	 */
	public Iterable<AnalysisTaskExecutor> getAllLiveExecutors() {
		
		return Collections.unmodifiableCollection(liveExecutors.values());
	}
	
	/**
	 * Moves executor from live queue to the ending queue
	 */
{'fraction_non_alphanumeric': 0.0990623726049735, 'fraction_numerical': 0.0, 'mean_word_length': 4.393406593406594, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4629773', 'n_tokens_mistral': 807, 'n_tokens_neox': 712, 'n_words': 167}