<commit_before>/*
 * Copyright (C) 2014 The TridentSDK Team
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package net.tridentsdk.server.threads;

import net.tridentsdk.api.docs.AccessNoDoc;
import net.tridentsdk.server.netty.client.ClientConnection;

import javax.annotation.concurrent.ThreadSafe;
import java.util.AbstractMap;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.*;

/**
 * Player handling thread manager
 *
 * @author The TridentSDK Team
 */
@ThreadSafe
public final class PlayerThreads {
    static final Map<PlayerThreads.ThreadPlayerHandler, Integer>                        THREAD_MAP  =
            new HashMap<>(16);
    static final Map<ClientConnection, PlayerThreads.ThreadPlayerWrapper>               WRAPPER_MAP =
            new HashMap<>();
    static final ConcurrentHashMap<ClientConnection, PlayerThreads.ThreadPlayerWrapper> CACHE_MAP   =
            new ConcurrentHashMap<>();

    static final ExecutorService SERVICE = Executors.newSingleThreadExecutor();

    static {
        PlayerThreads.SERVICE.execute(new Runnable() {
            @Override public void run() {
                for (int i = 0; i < 16; i++)
                    PlayerThreads.THREAD_MAP.put(new PlayerThreads.ThreadPlayerHandler(), Integer.valueOf(0));
            }
        });
    }

    private static final Map.Entry<?, ? extends Number> DEF_ENTRY = new AbstractMap.SimpleEntry<>(null, Long.MAX_VALUE);

    private PlayerThreads() {}

    /**
     * Gets the management tool for the player
     * <p/>
     * <p>This will put in a new value for the caches if cannot find for a new player</p><commit_msg>The amount of player threads is too damn high!<commit_after>/*
 * Copyright (C) 2014 The TridentSDK Team
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package net.tridentsdk.server.threads;

import net.tridentsdk.api.docs.AccessNoDoc;
import net.tridentsdk.server.netty.client.ClientConnection;

import javax.annotation.concurrent.ThreadSafe;
import java.util.AbstractMap;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.*;

/**
 * Player handling thread manager
 *
 * @author The TridentSDK Team
 */
@ThreadSafe
public final class PlayerThreads {
    static final Map<PlayerThreads.ThreadPlayerHandler, Integer>                        THREAD_MAP  =
            new HashMap<>(4);
    static final Map<ClientConnection, PlayerThreads.ThreadPlayerWrapper>               WRAPPER_MAP =
            new HashMap<>();
    static final ConcurrentHashMap<ClientConnection, PlayerThreads.ThreadPlayerWrapper> CACHE_MAP   =
            new ConcurrentHashMap<>();

    static final ExecutorService SERVICE = Executors.newSingleThreadExecutor();

    static {
        PlayerThreads.SERVICE.execute(new Runnable() {
            @Override public void run() {
                for (int i = 0; i < 4; i++)
                    PlayerThreads.THREAD_MAP.put(new PlayerThreads.ThreadPlayerHandler(), Integer.valueOf(0));
            }
        });
    }

    private static final Map.Entry<?, ? extends Number> DEF_ENTRY = new AbstractMap.SimpleEntry<>(null, Long.MAX_VALUE);

    private PlayerThreads() {}

    /**
     * Gets the management tool for the player
     * <p/>
     * <p>This will put in a new value for the caches if cannot find for a new player</p>
{'fraction_non_alphanumeric': 0.0863765580581675, 'fraction_numerical': 0.004373496610540126, 'mean_word_length': 3.14687216681777, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 1, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5216290', 'n_tokens_mistral': 1217, 'n_tokens_neox': 1186, 'n_words': 443}