Dropped useless IThreadPoolInitializer.
This commit is contained in:
@@ -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();
|
|
||||||
}
|
|
@@ -29,6 +29,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import com.l2jmobius.Config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author _dev_ (savormix)
|
* @author _dev_ (savormix)
|
||||||
* @author NB4L1
|
* @author NB4L1
|
||||||
@@ -40,15 +42,16 @@ public final class ThreadPool
|
|||||||
private static ScheduledThreadPoolExecutor SCHEDULED_THREAD_POOL_EXECUTOR;
|
private static ScheduledThreadPoolExecutor SCHEDULED_THREAD_POOL_EXECUTOR;
|
||||||
private static ThreadPoolExecutor 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))
|
if ((SCHEDULED_THREAD_POOL_EXECUTOR != null) || (THREAD_POOL_EXECUTOR != null))
|
||||||
{
|
{
|
||||||
throw new Exception("The thread pool has been already initialized!");
|
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));
|
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));
|
||||||
THREAD_POOL_EXECUTOR = new ThreadPoolExecutor(initializer.getThreadPoolSize(), initializer.getThreadPoolSize(), 1, TimeUnit.MINUTES, new LinkedBlockingQueue<>(), new PoolThreadFactory("L2JU-IT-", 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 ->
|
getThreadPools().forEach(tp ->
|
||||||
{
|
{
|
||||||
|
@@ -174,7 +174,7 @@ public class GameServer
|
|||||||
final long serverLoadStart = System.currentTimeMillis();
|
final long serverLoadStart = System.currentTimeMillis();
|
||||||
|
|
||||||
printSection("ThreadPool");
|
printSection("ThreadPool");
|
||||||
ThreadPool.initThreadPools(new GameThreadPools());
|
ThreadPool.init();
|
||||||
|
|
||||||
printSection("IdFactory");
|
printSection("IdFactory");
|
||||||
if (!IdFactory.getInstance().isInitialized())
|
if (!IdFactory.getInstance().isInitialized())
|
||||||
|
@@ -1,38 +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.gameserver;
|
|
||||||
|
|
||||||
import com.l2jmobius.Config;
|
|
||||||
import com.l2jmobius.commons.concurrent.IThreadPoolInitializer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author nos
|
|
||||||
*/
|
|
||||||
public final class GameThreadPools implements IThreadPoolInitializer
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public int getScheduledThreadPoolSize()
|
|
||||||
{
|
|
||||||
return Config.SCHEDULED_THREAD_POOL_COUNT != -1 ? Config.SCHEDULED_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_SCHEDULED_THREAD_POOL;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getThreadPoolSize()
|
|
||||||
{
|
|
||||||
return Config.INSTANT_THREAD_POOL_COUNT != -1 ? Config.INSTANT_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_INSTANT_THREAD_POOL;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -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();
|
|
||||||
}
|
|
@@ -29,6 +29,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import com.l2jmobius.Config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author _dev_ (savormix)
|
* @author _dev_ (savormix)
|
||||||
* @author NB4L1
|
* @author NB4L1
|
||||||
@@ -40,15 +42,16 @@ public final class ThreadPool
|
|||||||
private static ScheduledThreadPoolExecutor SCHEDULED_THREAD_POOL_EXECUTOR;
|
private static ScheduledThreadPoolExecutor SCHEDULED_THREAD_POOL_EXECUTOR;
|
||||||
private static ThreadPoolExecutor 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))
|
if ((SCHEDULED_THREAD_POOL_EXECUTOR != null) || (THREAD_POOL_EXECUTOR != null))
|
||||||
{
|
{
|
||||||
throw new Exception("The thread pool has been already initialized!");
|
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));
|
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));
|
||||||
THREAD_POOL_EXECUTOR = new ThreadPoolExecutor(initializer.getThreadPoolSize(), initializer.getThreadPoolSize(), 1, TimeUnit.MINUTES, new LinkedBlockingQueue<>(), new PoolThreadFactory("L2JU-IT-", 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 ->
|
getThreadPools().forEach(tp ->
|
||||||
{
|
{
|
||||||
|
@@ -178,7 +178,7 @@ public class GameServer
|
|||||||
final long serverLoadStart = System.currentTimeMillis();
|
final long serverLoadStart = System.currentTimeMillis();
|
||||||
|
|
||||||
printSection("ThreadPool");
|
printSection("ThreadPool");
|
||||||
ThreadPool.initThreadPools(new GameThreadPools());
|
ThreadPool.init();
|
||||||
|
|
||||||
printSection("IdFactory");
|
printSection("IdFactory");
|
||||||
if (!IdFactory.getInstance().isInitialized())
|
if (!IdFactory.getInstance().isInitialized())
|
||||||
|
@@ -1,38 +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.gameserver;
|
|
||||||
|
|
||||||
import com.l2jmobius.Config;
|
|
||||||
import com.l2jmobius.commons.concurrent.IThreadPoolInitializer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author nos
|
|
||||||
*/
|
|
||||||
public final class GameThreadPools implements IThreadPoolInitializer
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public int getScheduledThreadPoolSize()
|
|
||||||
{
|
|
||||||
return Config.SCHEDULED_THREAD_POOL_COUNT != -1 ? Config.SCHEDULED_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_SCHEDULED_THREAD_POOL;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getThreadPoolSize()
|
|
||||||
{
|
|
||||||
return Config.INSTANT_THREAD_POOL_COUNT != -1 ? Config.INSTANT_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_INSTANT_THREAD_POOL;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -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();
|
|
||||||
}
|
|
@@ -29,6 +29,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import com.l2jmobius.Config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author _dev_ (savormix)
|
* @author _dev_ (savormix)
|
||||||
* @author NB4L1
|
* @author NB4L1
|
||||||
@@ -40,15 +42,16 @@ public final class ThreadPool
|
|||||||
private static ScheduledThreadPoolExecutor SCHEDULED_THREAD_POOL_EXECUTOR;
|
private static ScheduledThreadPoolExecutor SCHEDULED_THREAD_POOL_EXECUTOR;
|
||||||
private static ThreadPoolExecutor 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))
|
if ((SCHEDULED_THREAD_POOL_EXECUTOR != null) || (THREAD_POOL_EXECUTOR != null))
|
||||||
{
|
{
|
||||||
throw new Exception("The thread pool has been already initialized!");
|
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));
|
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));
|
||||||
THREAD_POOL_EXECUTOR = new ThreadPoolExecutor(initializer.getThreadPoolSize(), initializer.getThreadPoolSize(), 1, TimeUnit.MINUTES, new LinkedBlockingQueue<>(), new PoolThreadFactory("L2JU-IT-", 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 ->
|
getThreadPools().forEach(tp ->
|
||||||
{
|
{
|
||||||
|
@@ -178,7 +178,7 @@ public class GameServer
|
|||||||
final long serverLoadStart = System.currentTimeMillis();
|
final long serverLoadStart = System.currentTimeMillis();
|
||||||
|
|
||||||
printSection("ThreadPool");
|
printSection("ThreadPool");
|
||||||
ThreadPool.initThreadPools(new GameThreadPools());
|
ThreadPool.init();
|
||||||
|
|
||||||
printSection("IdFactory");
|
printSection("IdFactory");
|
||||||
if (!IdFactory.getInstance().isInitialized())
|
if (!IdFactory.getInstance().isInitialized())
|
||||||
|
@@ -1,38 +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.gameserver;
|
|
||||||
|
|
||||||
import com.l2jmobius.Config;
|
|
||||||
import com.l2jmobius.commons.concurrent.IThreadPoolInitializer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author nos
|
|
||||||
*/
|
|
||||||
public final class GameThreadPools implements IThreadPoolInitializer
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public int getScheduledThreadPoolSize()
|
|
||||||
{
|
|
||||||
return Config.SCHEDULED_THREAD_POOL_COUNT != -1 ? Config.SCHEDULED_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_SCHEDULED_THREAD_POOL;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getThreadPoolSize()
|
|
||||||
{
|
|
||||||
return Config.INSTANT_THREAD_POOL_COUNT != -1 ? Config.INSTANT_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_INSTANT_THREAD_POOL;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -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();
|
|
||||||
}
|
|
@@ -29,6 +29,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import com.l2jmobius.Config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author _dev_ (savormix)
|
* @author _dev_ (savormix)
|
||||||
* @author NB4L1
|
* @author NB4L1
|
||||||
@@ -40,15 +42,16 @@ public final class ThreadPool
|
|||||||
private static ScheduledThreadPoolExecutor SCHEDULED_THREAD_POOL_EXECUTOR;
|
private static ScheduledThreadPoolExecutor SCHEDULED_THREAD_POOL_EXECUTOR;
|
||||||
private static ThreadPoolExecutor 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))
|
if ((SCHEDULED_THREAD_POOL_EXECUTOR != null) || (THREAD_POOL_EXECUTOR != null))
|
||||||
{
|
{
|
||||||
throw new Exception("The thread pool has been already initialized!");
|
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));
|
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));
|
||||||
THREAD_POOL_EXECUTOR = new ThreadPoolExecutor(initializer.getThreadPoolSize(), initializer.getThreadPoolSize(), 1, TimeUnit.MINUTES, new LinkedBlockingQueue<>(), new PoolThreadFactory("L2JU-IT-", 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 ->
|
getThreadPools().forEach(tp ->
|
||||||
{
|
{
|
||||||
|
@@ -178,7 +178,7 @@ public class GameServer
|
|||||||
final long serverLoadStart = System.currentTimeMillis();
|
final long serverLoadStart = System.currentTimeMillis();
|
||||||
|
|
||||||
printSection("ThreadPool");
|
printSection("ThreadPool");
|
||||||
ThreadPool.initThreadPools(new GameThreadPools());
|
ThreadPool.init();
|
||||||
|
|
||||||
printSection("IdFactory");
|
printSection("IdFactory");
|
||||||
if (!IdFactory.getInstance().isInitialized())
|
if (!IdFactory.getInstance().isInitialized())
|
||||||
|
@@ -1,38 +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.gameserver;
|
|
||||||
|
|
||||||
import com.l2jmobius.Config;
|
|
||||||
import com.l2jmobius.commons.concurrent.IThreadPoolInitializer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author nos
|
|
||||||
*/
|
|
||||||
public final class GameThreadPools implements IThreadPoolInitializer
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public int getScheduledThreadPoolSize()
|
|
||||||
{
|
|
||||||
return Config.SCHEDULED_THREAD_POOL_COUNT != -1 ? Config.SCHEDULED_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_SCHEDULED_THREAD_POOL;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getThreadPoolSize()
|
|
||||||
{
|
|
||||||
return Config.INSTANT_THREAD_POOL_COUNT != -1 ? Config.INSTANT_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_INSTANT_THREAD_POOL;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -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();
|
|
||||||
}
|
|
@@ -29,6 +29,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import com.l2jmobius.Config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author _dev_ (savormix)
|
* @author _dev_ (savormix)
|
||||||
* @author NB4L1
|
* @author NB4L1
|
||||||
@@ -40,15 +42,16 @@ public final class ThreadPool
|
|||||||
private static ScheduledThreadPoolExecutor SCHEDULED_THREAD_POOL_EXECUTOR;
|
private static ScheduledThreadPoolExecutor SCHEDULED_THREAD_POOL_EXECUTOR;
|
||||||
private static ThreadPoolExecutor 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))
|
if ((SCHEDULED_THREAD_POOL_EXECUTOR != null) || (THREAD_POOL_EXECUTOR != null))
|
||||||
{
|
{
|
||||||
throw new Exception("The thread pool has been already initialized!");
|
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));
|
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));
|
||||||
THREAD_POOL_EXECUTOR = new ThreadPoolExecutor(initializer.getThreadPoolSize(), initializer.getThreadPoolSize(), 1, TimeUnit.MINUTES, new LinkedBlockingQueue<>(), new PoolThreadFactory("L2JU-IT-", 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 ->
|
getThreadPools().forEach(tp ->
|
||||||
{
|
{
|
||||||
|
@@ -181,7 +181,7 @@ public class GameServer
|
|||||||
DatabaseFactory.getInstance();
|
DatabaseFactory.getInstance();
|
||||||
|
|
||||||
Util.printSection("ThreadPool");
|
Util.printSection("ThreadPool");
|
||||||
ThreadPool.initThreadPools(new GameThreadPools());
|
ThreadPool.init();
|
||||||
if (Config.DEADLOCKCHECK_INTIAL_TIME > 0)
|
if (Config.DEADLOCKCHECK_INTIAL_TIME > 0)
|
||||||
{
|
{
|
||||||
ThreadPool.scheduleAtFixedRate(DeadlockDetector.getInstance(), Config.DEADLOCKCHECK_INTIAL_TIME, Config.DEADLOCKCHECK_DELAY_TIME);
|
ThreadPool.scheduleAtFixedRate(DeadlockDetector.getInstance(), Config.DEADLOCKCHECK_INTIAL_TIME, Config.DEADLOCKCHECK_DELAY_TIME);
|
||||||
|
@@ -1,38 +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.gameserver;
|
|
||||||
|
|
||||||
import com.l2jmobius.Config;
|
|
||||||
import com.l2jmobius.commons.concurrent.IThreadPoolInitializer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author nos
|
|
||||||
*/
|
|
||||||
public final class GameThreadPools implements IThreadPoolInitializer
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public int getScheduledThreadPoolSize()
|
|
||||||
{
|
|
||||||
return Config.SCHEDULED_THREAD_POOL_COUNT != -1 ? Config.SCHEDULED_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_SCHEDULED_THREAD_POOL;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getThreadPoolSize()
|
|
||||||
{
|
|
||||||
return Config.INSTANT_THREAD_POOL_COUNT != -1 ? Config.INSTANT_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_INSTANT_THREAD_POOL;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -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();
|
|
||||||
}
|
|
@@ -29,6 +29,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import com.l2jmobius.Config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author _dev_ (savormix)
|
* @author _dev_ (savormix)
|
||||||
* @author NB4L1
|
* @author NB4L1
|
||||||
@@ -40,15 +42,16 @@ public final class ThreadPool
|
|||||||
private static ScheduledThreadPoolExecutor SCHEDULED_THREAD_POOL_EXECUTOR;
|
private static ScheduledThreadPoolExecutor SCHEDULED_THREAD_POOL_EXECUTOR;
|
||||||
private static ThreadPoolExecutor 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))
|
if ((SCHEDULED_THREAD_POOL_EXECUTOR != null) || (THREAD_POOL_EXECUTOR != null))
|
||||||
{
|
{
|
||||||
throw new Exception("The thread pool has been already initialized!");
|
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));
|
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));
|
||||||
THREAD_POOL_EXECUTOR = new ThreadPoolExecutor(initializer.getThreadPoolSize(), initializer.getThreadPoolSize(), 1, TimeUnit.MINUTES, new LinkedBlockingQueue<>(), new PoolThreadFactory("L2JU-IT-", 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 ->
|
getThreadPools().forEach(tp ->
|
||||||
{
|
{
|
||||||
|
@@ -162,7 +162,7 @@ public final class GameServer
|
|||||||
final long serverLoadStart = System.currentTimeMillis();
|
final long serverLoadStart = System.currentTimeMillis();
|
||||||
|
|
||||||
printSection("ThreadPool");
|
printSection("ThreadPool");
|
||||||
ThreadPool.initThreadPools(new GameThreadPools());
|
ThreadPool.init();
|
||||||
|
|
||||||
printSection("IdFactory");
|
printSection("IdFactory");
|
||||||
if (!IdFactory.getInstance().isInitialized())
|
if (!IdFactory.getInstance().isInitialized())
|
||||||
|
@@ -1,38 +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.gameserver;
|
|
||||||
|
|
||||||
import com.l2jmobius.Config;
|
|
||||||
import com.l2jmobius.commons.concurrent.IThreadPoolInitializer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author nos
|
|
||||||
*/
|
|
||||||
public final class GameThreadPools implements IThreadPoolInitializer
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public int getScheduledThreadPoolSize()
|
|
||||||
{
|
|
||||||
return Config.SCHEDULED_THREAD_POOL_COUNT != -1 ? Config.SCHEDULED_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_SCHEDULED_THREAD_POOL;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getThreadPoolSize()
|
|
||||||
{
|
|
||||||
return Config.INSTANT_THREAD_POOL_COUNT != -1 ? Config.INSTANT_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_INSTANT_THREAD_POOL;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -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();
|
|
||||||
}
|
|
@@ -29,6 +29,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import com.l2jmobius.Config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author _dev_ (savormix)
|
* @author _dev_ (savormix)
|
||||||
* @author NB4L1
|
* @author NB4L1
|
||||||
@@ -40,15 +42,16 @@ public final class ThreadPool
|
|||||||
private static ScheduledThreadPoolExecutor SCHEDULED_THREAD_POOL_EXECUTOR;
|
private static ScheduledThreadPoolExecutor SCHEDULED_THREAD_POOL_EXECUTOR;
|
||||||
private static ThreadPoolExecutor 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))
|
if ((SCHEDULED_THREAD_POOL_EXECUTOR != null) || (THREAD_POOL_EXECUTOR != null))
|
||||||
{
|
{
|
||||||
throw new Exception("The thread pool has been already initialized!");
|
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));
|
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));
|
||||||
THREAD_POOL_EXECUTOR = new ThreadPoolExecutor(initializer.getThreadPoolSize(), initializer.getThreadPoolSize(), 1, TimeUnit.MINUTES, new LinkedBlockingQueue<>(), new PoolThreadFactory("L2JU-IT-", 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 ->
|
getThreadPools().forEach(tp ->
|
||||||
{
|
{
|
||||||
|
@@ -174,7 +174,7 @@ public class GameServer
|
|||||||
final long serverLoadStart = System.currentTimeMillis();
|
final long serverLoadStart = System.currentTimeMillis();
|
||||||
|
|
||||||
printSection("ThreadPool");
|
printSection("ThreadPool");
|
||||||
ThreadPool.initThreadPools(new GameThreadPools());
|
ThreadPool.init();
|
||||||
|
|
||||||
printSection("IdFactory");
|
printSection("IdFactory");
|
||||||
if (!IdFactory.getInstance().isInitialized())
|
if (!IdFactory.getInstance().isInitialized())
|
||||||
|
@@ -1,38 +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.gameserver;
|
|
||||||
|
|
||||||
import com.l2jmobius.Config;
|
|
||||||
import com.l2jmobius.commons.concurrent.IThreadPoolInitializer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author nos
|
|
||||||
*/
|
|
||||||
public final class GameThreadPools implements IThreadPoolInitializer
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public int getScheduledThreadPoolSize()
|
|
||||||
{
|
|
||||||
return Config.SCHEDULED_THREAD_POOL_COUNT != -1 ? Config.SCHEDULED_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_SCHEDULED_THREAD_POOL;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getThreadPoolSize()
|
|
||||||
{
|
|
||||||
return Config.INSTANT_THREAD_POOL_COUNT != -1 ? Config.INSTANT_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_INSTANT_THREAD_POOL;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -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();
|
|
||||||
}
|
|
@@ -29,6 +29,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import com.l2jmobius.Config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author _dev_ (savormix)
|
* @author _dev_ (savormix)
|
||||||
* @author NB4L1
|
* @author NB4L1
|
||||||
@@ -40,15 +42,16 @@ public final class ThreadPool
|
|||||||
private static ScheduledThreadPoolExecutor SCHEDULED_THREAD_POOL_EXECUTOR;
|
private static ScheduledThreadPoolExecutor SCHEDULED_THREAD_POOL_EXECUTOR;
|
||||||
private static ThreadPoolExecutor 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))
|
if ((SCHEDULED_THREAD_POOL_EXECUTOR != null) || (THREAD_POOL_EXECUTOR != null))
|
||||||
{
|
{
|
||||||
throw new Exception("The thread pool has been already initialized!");
|
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));
|
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));
|
||||||
THREAD_POOL_EXECUTOR = new ThreadPoolExecutor(initializer.getThreadPoolSize(), initializer.getThreadPoolSize(), 1, TimeUnit.MINUTES, new LinkedBlockingQueue<>(), new PoolThreadFactory("L2JU-IT-", 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 ->
|
getThreadPools().forEach(tp ->
|
||||||
{
|
{
|
||||||
|
@@ -174,7 +174,7 @@ public class GameServer
|
|||||||
final long serverLoadStart = System.currentTimeMillis();
|
final long serverLoadStart = System.currentTimeMillis();
|
||||||
|
|
||||||
printSection("ThreadPool");
|
printSection("ThreadPool");
|
||||||
ThreadPool.initThreadPools(new GameThreadPools());
|
ThreadPool.init();
|
||||||
|
|
||||||
printSection("IdFactory");
|
printSection("IdFactory");
|
||||||
if (!IdFactory.getInstance().isInitialized())
|
if (!IdFactory.getInstance().isInitialized())
|
||||||
|
@@ -1,38 +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.gameserver;
|
|
||||||
|
|
||||||
import com.l2jmobius.Config;
|
|
||||||
import com.l2jmobius.commons.concurrent.IThreadPoolInitializer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author nos
|
|
||||||
*/
|
|
||||||
public final class GameThreadPools implements IThreadPoolInitializer
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public int getScheduledThreadPoolSize()
|
|
||||||
{
|
|
||||||
return Config.SCHEDULED_THREAD_POOL_COUNT != -1 ? Config.SCHEDULED_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_SCHEDULED_THREAD_POOL;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getThreadPoolSize()
|
|
||||||
{
|
|
||||||
return Config.INSTANT_THREAD_POOL_COUNT != -1 ? Config.INSTANT_THREAD_POOL_COUNT : Runtime.getRuntime().availableProcessors() * Config.THREADS_PER_INSTANT_THREAD_POOL;
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user