Switch to Odeum for executors.

This commit is contained in:
sk89q 2014-08-02 11:24:25 -07:00
parent 387431c9c7
commit bf48361b10
4 changed files with 15 additions and 54 deletions

13
pom.xml
View File

@ -192,6 +192,14 @@
<type>jar</type>
</dependency>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>odeum</artifactId>
<version>0.2.0-SNAPSHOT</version>
<scope>compile</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
@ -384,6 +392,7 @@
<include>com.jolbox:bonecp</include>
<include>org.flywaydb:flyway-core</include>
<include>com.sk89q:squirrelid</include>
<include>com.sk89q:odeum</include>
</includes>
</artifactSet>
<relocations>
@ -399,6 +408,10 @@
<pattern>com.sk89q.squirrelid</pattern>
<shadedPattern>com.sk89q.worldguard.util.profile</shadedPattern>
</relocation>
<relocation>
<pattern>com.sk89q.odeum</pattern>
<shadedPattern>com.sk89q.worldguard.internal.odeum</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>

View File

@ -29,6 +29,7 @@
import com.sk89q.minecraft.util.commands.MissingNestedCommandException;
import com.sk89q.minecraft.util.commands.SimpleInjector;
import com.sk89q.minecraft.util.commands.WrappedCommandException;
import com.sk89q.odeum.concurrency.EvenMoreExecutors;
import com.sk89q.squirrelid.cache.HashMapCache;
import com.sk89q.squirrelid.cache.ProfileCache;
import com.sk89q.squirrelid.cache.SQLiteCache;
@ -50,7 +51,6 @@
import com.sk89q.worldguard.protection.GlobalRegionManager;
import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.util.FatalConfigurationLoadingException;
import com.sk89q.worldguard.util.concurrency.EvenMoreExecutors;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;

View File

@ -22,9 +22,9 @@
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
import com.sk89q.odeum.concurrency.EvenMoreExecutors;
import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.util.concurrency.EvenMoreExecutors;
import javax.annotation.Nullable;
import java.util.HashMap;

View File

@ -1,52 +0,0 @@
/*
* WorldGuard, a suite of tools for Minecraft
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldGuard team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser 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 Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldguard.util.concurrency;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* Even more {@code ExecutorService} factory methods.
*/
public final class EvenMoreExecutors {
private EvenMoreExecutors() {
}
/**
* Creates a thread pool that creates new threads as needed up to
* a maximum number of threads, but will reuse previously constructed
* threads when they are available.
*
* @return the newly created thread pool
*/
public static ExecutorService newBoundedCachedThreadPool(int minThreads, int maxThreads, int maxPoolSize) {
ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
minThreads, maxThreads,
60L, TimeUnit.SECONDS,
new LinkedBlockingQueue<Runnable>(maxPoolSize));
threadPoolExecutor.allowCoreThreadTimeOut(true);
return threadPoolExecutor;
}
}