<commit_before>package com.ardverk.dht2;

import java.io.Closeable;
import java.util.EnumMap;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;

import org.ardverk.collection.IdentityHashSet;
import org.ardverk.concurrent.AsyncFuture;
import org.ardverk.concurrent.AsyncFutureGroup;
import org.ardverk.concurrent.AsyncProcess;
import org.ardverk.concurrent.AsyncProcessExecutorService;
import org.ardverk.concurrent.ExecutorGroup;
import org.ardverk.concurrent.ExecutorQueue;
import org.ardverk.concurrent.ExecutorUtils;

import com.ardverk.dht.concurrent.ArdverkFuture;
import com.ardverk.dht.concurrent.ArdverkFutureTask;

/**
 * The {@link FutureManager} manages {@link AsyncFuture}s.
 */
public class FutureManager implements Closeable {
    
    private static final AsyncProcessExecutorService EXECUTOR 
        = ExecutorUtils.newCachedThreadPool("FutureManagerThread");
    
    private static final int DEFAULT_CONCURRENCY_LEVEL = 4;
    
    private final Map<QueueKey, ExecutorQueue<? extends Runnable>> executors 
        = new EnumMap<QueueKey, ExecutorQueue<? extends Runnable>>(QueueKey.class);
    
    private final Set<AsyncFuture<?>> futures 
        = new IdentityHashSet<AsyncFuture<?>>();
    
    private boolean open = true;
    
    public FutureManager() {
        this (DEFAULT_CONCURRENCY_LEVEL);
    }
    
    public FutureManager(int concurrencyLevel) {
        executors.put(QueueKey.PARALLEL, new ExecutorGroup(EXECUTOR));
        executors.put(QueueKey.SERIAL, new AsyncFutureGroup(EXECUTOR, concurrencyLevel));
    }
    
    @Override
    public synchronized void close() {
        if (!open) {<commit_msg>Adding a few factory methods<commit_after>package com.ardverk.dht2;

import java.io.Closeable;
import java.util.EnumMap;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;

import org.ardverk.collection.IdentityHashSet;
import org.ardverk.concurrent.AsyncFuture;
import org.ardverk.concurrent.AsyncFutureGroup;
import org.ardverk.concurrent.AsyncProcess;
import org.ardverk.concurrent.AsyncProcessExecutorService;
import org.ardverk.concurrent.ExecutorGroup;
import org.ardverk.concurrent.ExecutorQueue;
import org.ardverk.concurrent.ExecutorUtils;
import org.ardverk.concurrent.Scheduler;

import com.ardverk.dht.concurrent.ArdverkFuture;
import com.ardverk.dht.concurrent.ArdverkFutureTask;

/**
 * The {@link FutureManager} manages {@link AsyncFuture}s.
 */
public class FutureManager implements Closeable {
    
    private static final AsyncProcessExecutorService EXECUTOR 
        = ExecutorUtils.newCachedThreadPool("FutureManagerThread");
    
    private static final int DEFAULT_CONCURRENCY_LEVEL = 4;
    
    private final Map<QueueKey, ExecutorQueue<? extends Runnable>> executors 
        = new EnumMap<QueueKey, ExecutorQueue<? extends Runnable>>(QueueKey.class);
    
    private final Set<AsyncFuture<?>> futures 
        = new IdentityHashSet<AsyncFuture<?>>();
    
    private boolean open = true;
    
    public FutureManager() {
        this (DEFAULT_CONCURRENCY_LEVEL);
    }
    
    public FutureManager(int concurrencyLevel) {
        executors.put(QueueKey.PARALLEL, new ExecutorGroup(EXECUTOR));
        executors.put(QueueKey.SERIAL, new AsyncFutureGroup(EXECUTOR, concurrencyLevel));
    }
    
    public ExecutorGroup createExecutorGroup() {
        return new ExecutorGroup(EXECUTOR);
    }
    
    public ExecutorGroup createExecutorGroup(Scheduler scheduler) {
        return new ExecutorGroup(EXECUTOR, scheduler);
    }
    
    public AsyncFutureGroup createAsyncFutureGroup(int concurrencyLevel) {
        return new AsyncFutureGroup(EXECUTOR, concurrencyLevel);
    }
    
    @Override
    public synchronized void close() {
        if (!open) {
{'fraction_non_alphanumeric': 0.0893751647772212, 'fraction_numerical': 0.0010545742156604272, 'mean_word_length': 4.19015047879617, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '5830113', 'n_tokens_mistral': 1119, 'n_tokens_neox': 1101, 'n_words': 224}