Dropped useless IThreadPoolInitializer.

This commit is contained in:
MobiusDev
2018-04-02 16:06:00 +00:00
parent 0d3a422ee3
commit 9f16536250
32 changed files with 56 additions and 528 deletions

View File

@ -1,24 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* 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 com.l2jmobius.commons.concurrent;
public interface IThreadPoolInitializer
{
int getScheduledThreadPoolSize();
int getThreadPoolSize();
}

View File

@ -29,6 +29,8 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Logger;
import java.util.stream.Stream;
import com.l2jmobius.Config;
/**
* @author _dev_ (savormix)
* @author NB4L1
@ -40,15 +42,16 @@ public final class ThreadPool
private static ScheduledThreadPoolExecutor SCHEDULED_THREAD_POOL_EXECUTOR;
private static ThreadPoolExecutor THREAD_POOL_EXECUTOR;
public static void initThreadPools(IThreadPoolInitializer initializer) throws Exception
public static void init() throws Exception
{
if ((SCHEDULED_THREAD_POOL_EXECUTOR != null) || (THREAD_POOL_EXECUTOR != null))
{
throw new Exception("The thread pool has been already initialized!");
}
SCHEDULED_THREAD_POOL_EXECUTOR = new ScheduledThreadPoolExecutor(initializer.getScheduledThreadPoolSize(), new PoolThreadFactory("L2JU-SP-", Thread.NORM_PRIORITY));
THREAD_POOL_EXECUTOR = new ThreadPoolExecutor(initializer.getThreadPoolSize(), initializer.getThreadPoolSize(), 1, TimeUnit.MINUTES, new LinkedBlockingQueue<>(), new PoolThreadFactory("L2JU-IT-", Thread.NORM_PRIORITY));
SCHEDULED_THREAD_POOL_EXECUTOR = new ScheduledThreadPoolExecutor(Config.SCHEDULED_THREAD_POOL_COUNT != -1 ? Config.SCHEDULED_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_SCHEDULED_THREAD_POOL, new PoolThreadFactory("L2JM-S-", Thread.NORM_PRIORITY));
final int poolCount = Config.INSTANT_THREAD_POOL_COUNT != -1 ? Config.INSTANT_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_INSTANT_THREAD_POOL;
THREAD_POOL_EXECUTOR = new ThreadPoolExecutor(poolCount, poolCount, 1, TimeUnit.MINUTES, new LinkedBlockingQueue<>(), new PoolThreadFactory("L2JM-I-", Thread.NORM_PRIORITY));
getThreadPools().forEach(tp ->
{