<commit_before>package org.fidonet.binkp;

import org.fidonet.types.Link;

import java.util.concurrent.*;

/**
 * Created by IntelliJ IDEA.
 * Author: <NAME>
 * E-Mail: <EMAIL>
 * Date: 9/20/12
 * Time: 10:30 AM
 */
public class Runner {

    private ExecutorService threadPoolExecutor;

    public Runner() {
        threadPoolExecutor = Executors.newCachedThreadPool();
    }

    public void poll(Link link, final SessionContext context) throws Exception {
        final Client client = new Client(link);
        Runnable clientRun = new Runnable() {

            public void waitSessionFinish () throws InterruptedException {
                for (;;) {
                    Thread.sleep(500);
                    if (context.isReceivingIsFinish() && context.isSendingIsFinish() ||
                            context.getState().equals(SessionState.STATE_ERR) ||
                            context.getState().equals(SessionState.STATE_END)) {
                        break;
                    }
                }
            }

            @Override
            public void run() {
                try {
                    client.run(context);
                    if (client.isConnect()) {
                        waitSessionFinish();
                    }
                } catch (Exception e) {
                    // todo logger
                } finally {
                    client.stop(context);
                }<commit_msg>Use own ThreadPoolExecuter instead fo chached. Core thread pull size set to 3.<commit_after>package org.fidonet.binkp;

import org.fidonet.types.Link;

import java.util.concurrent.*;

/**
 * Created by IntelliJ IDEA.
 * Author: <NAME>
 * E-Mail: <EMAIL>
 * Date: 9/20/12
 * Time: 10:30 AM
 */
public class Runner {

    private ExecutorService threadPoolExecutor;

    public Runner() {
        threadPoolExecutor = new ThreadPoolExecutor(3, Integer.MAX_VALUE,
                                                    60L, TimeUnit.SECONDS,
                                                    new SynchronousQueue<Runnable>());
    }

    public void poll(Link link, final SessionContext context) throws Exception {
        final Client client = new Client(link);
        Runnable clientRun = new Runnable() {

            public void waitSessionFinish () throws InterruptedException {
                for (;;) {
                    Thread.sleep(500);
                    if (context.isReceivingIsFinish() && context.isSendingIsFinish() ||
                            context.getState().equals(SessionState.STATE_ERR) ||
                            context.getState().equals(SessionState.STATE_END)) {
                        break;
                    }
                }
            }

            @Override
            public void run() {
                try {
                    client.run(context);
                    if (client.isConnect()) {
                        waitSessionFinish();
                    }
                } catch (Exception e) {
                    // todo logger
                } finally {
                    client.stop(context);
                }
{'fraction_non_alphanumeric': 0.09225329476052717, 'fraction_numerical': 0.00900032144005143, 'mean_word_length': 1.3398496240601503, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4733242', 'n_tokens_mistral': 810, 'n_tokens_neox': 726, 'n_words': 170}