package com.tzld.piaoquan.ad.engine.commons.thread;

import com.google.common.util.concurrent.ThreadFactoryBuilder;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author dyp
 */
public final class ThreadPoolFactory {
    private final static ExecutorService DEFAULT = new CommonThreadPoolExecutor(
            512,
            512,
            0L, TimeUnit.SECONDS,
            new LinkedBlockingQueue<>(5000),
            new ThreadFactoryBuilder().setNameFormat("DEFAULT-%d").build(),
            new ThreadPoolExecutor.AbortPolicy());
    private final static ExecutorService FEATURE = new CommonThreadPoolExecutor(
            256,
            256,
            0L, TimeUnit.SECONDS,
            new LinkedBlockingQueue<>(5000),
            new ThreadFactoryBuilder().setNameFormat("Feature-%d").build(),
            new ThreadPoolExecutor.AbortPolicy());

    private final static ExecutorService SCORE = new CommonThreadPoolExecutor(
            512,
            512,
            0L, TimeUnit.SECONDS,
            new LinkedBlockingQueue<>(5000),
            new ThreadFactoryBuilder().setNameFormat("SCORE-%d").build(),
            new ThreadPoolExecutor.AbortPolicy());

    public static ExecutorService defaultPool() {
        return DEFAULT;
    }

    public static ExecutorService feature() {
        return FEATURE;
    }

    public static ExecutorService score() {
        return SCORE;
    }


}
