mirror of https://github.com/longtai-cn/hippo4j
parent
227f8893e0
commit
4ae492c8b0
@ -0,0 +1,33 @@
|
||||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
@ -0,0 +1,59 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>cn.hippo4j</groupId>
|
||||
<artifactId>hippo4j-all</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>hippo4j-core</artifactId>
|
||||
<name>${project.artifactId}</name>
|
||||
<description>${project.artifactId}</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.hippo4j</groupId>
|
||||
<artifactId>hippo4j-common</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<Implementation-Title>${project.artifactId}</Implementation-Title>
|
||||
<Implementation-Version>${project.version}</Implementation-Version>
|
||||
<Build-Time>${maven.build.timestamp}</Build-Time>
|
||||
<Built-By>chen.ma</Built-By>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.10.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -1,7 +1,7 @@
|
||||
package cn.hippo4j.starter.core;
|
||||
package cn.hippo4j.core.executor.manage;
|
||||
|
||||
import cn.hippo4j.common.model.PoolParameter;
|
||||
import cn.hippo4j.starter.wrapper.DynamicThreadPoolWrapper;
|
||||
import cn.hippo4j.core.executor.DynamicThreadPoolWrapper;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import java.util.List;
|
@ -1,8 +1,6 @@
|
||||
package cn.hippo4j.starter.common;
|
||||
package cn.hippo4j.core.executor.support;
|
||||
|
||||
import cn.hippo4j.starter.core.DynamicThreadPoolExecutor;
|
||||
import cn.hippo4j.starter.toolkit.thread.QueueTypeEnum;
|
||||
import cn.hippo4j.starter.toolkit.thread.ThreadPoolBuilder;
|
||||
import cn.hippo4j.core.executor.DynamicThreadPoolExecutor;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cn.hippo4j.starter.toolkit.thread;
|
||||
package cn.hippo4j.core.executor.support;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cn.hippo4j.starter.toolkit.thread;
|
||||
package cn.hippo4j.core.executor.support;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cn.hippo4j.starter.toolkit.thread;
|
||||
package cn.hippo4j.core.executor.support;
|
||||
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.RejectedExecutionException;
|
@ -1,4 +1,4 @@
|
||||
package cn.hippo4j.starter.toolkit.thread;
|
||||
package cn.hippo4j.core.executor.support;
|
||||
|
||||
import cn.hippo4j.common.design.builder.Builder;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cn.hippo4j.starter.toolkit.thread;
|
||||
package cn.hippo4j.core.executor.support;
|
||||
|
||||
import cn.hippo4j.common.design.builder.Builder;
|
||||
import cn.hippo4j.common.toolkit.Assert;
|
@ -1,6 +1,7 @@
|
||||
package cn.hippo4j.starter.toolkit.thread;
|
||||
package cn.hippo4j.core.executor.support;
|
||||
|
||||
import cn.hippo4j.starter.toolkit.ArrayUtil;
|
||||
|
||||
import cn.hippo4j.common.toolkit.ArrayUtil;
|
||||
|
||||
import java.util.concurrent.*;
|
||||
|
@ -0,0 +1,33 @@
|
||||
package cn.hippo4j.core.proxy;
|
||||
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.util.concurrent.RejectedExecutionHandler;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
/**
|
||||
* Rejected proxy util.
|
||||
*
|
||||
* @author chen.ma
|
||||
* @date 2022/2/22 21:56
|
||||
*/
|
||||
public class RejectedProxyUtil {
|
||||
|
||||
/**
|
||||
* Proxy rejected execution.
|
||||
*
|
||||
* @param rejectedExecutionHandler
|
||||
* @param rejectedNum
|
||||
* @return
|
||||
*/
|
||||
public static RejectedExecutionHandler createProxy(RejectedExecutionHandler rejectedExecutionHandler, AtomicLong rejectedNum) {
|
||||
RejectedExecutionHandler rejectedProxy = (RejectedExecutionHandler) Proxy
|
||||
.newProxyInstance(
|
||||
rejectedExecutionHandler.getClass().getClassLoader(),
|
||||
new Class[]{RejectedExecutionHandler.class},
|
||||
new RejectedProxyInvocationHandler(rejectedExecutionHandler, rejectedNum)
|
||||
);
|
||||
|
||||
return rejectedProxy;
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package cn.hippo4j.starter.spi;
|
||||
package cn.hippo4j.core.spi;
|
||||
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cn.hippo4j.starter.spi;
|
||||
package cn.hippo4j.core.spi;
|
||||
|
||||
import java.util.concurrent.RejectedExecutionHandler;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cn.hippo4j.starter.spi;
|
||||
package cn.hippo4j.core.spi;
|
||||
|
||||
/**
|
||||
* Service loader instantiation exception.
|
@ -1,42 +0,0 @@
|
||||
package cn.hippo4j.starter.toolkit;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
|
||||
/**
|
||||
* Array util.
|
||||
*
|
||||
* @author chen.ma
|
||||
* @date 2021/7/5 21:54
|
||||
*/
|
||||
public class ArrayUtil {
|
||||
|
||||
public static <T> T[] addAll(final T[] array1, @SuppressWarnings("unchecked") final T... array2) {
|
||||
if (array1 == null) {
|
||||
return clone(array2);
|
||||
} else if (array2 == null) {
|
||||
return clone(array1);
|
||||
}
|
||||
final Class<?> type1 = array1.getClass().getComponentType();
|
||||
@SuppressWarnings("unchecked") final T[] joinedArray = (T[]) Array.newInstance(type1, array1.length + array2.length);
|
||||
System.arraycopy(array1, 0, joinedArray, 0, array1.length);
|
||||
try {
|
||||
System.arraycopy(array2, 0, joinedArray, array1.length, array2.length);
|
||||
} catch (final ArrayStoreException ase) {
|
||||
final Class<?> type2 = array2.getClass().getComponentType();
|
||||
if (!type1.isAssignableFrom(type2)) {
|
||||
throw new IllegalArgumentException("Cannot store " + type2.getName() + " in an array of "
|
||||
+ type1.getName(), ase);
|
||||
}
|
||||
throw ase;
|
||||
}
|
||||
return joinedArray;
|
||||
}
|
||||
|
||||
public static <T> T[] clone(final T[] array) {
|
||||
if (array == null) {
|
||||
return null;
|
||||
}
|
||||
return array.clone();
|
||||
}
|
||||
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
package cn.hippo4j.starter.toolkit.thread;
|
||||
|
||||
/**
|
||||
* Thread util.
|
||||
*
|
||||
* @author chen.ma
|
||||
* @date 2021/12/6 23:34
|
||||
*/
|
||||
public class ThreadUtil {
|
||||
|
||||
/**
|
||||
* 创建新线程.
|
||||
*
|
||||
* @param runnable {@link Runnable}
|
||||
* @param name 线程名
|
||||
* @param isDaemon 是否守护线程
|
||||
* @return {@link Thread}
|
||||
*/
|
||||
public static Thread newThread(Runnable runnable, String name, boolean isDaemon) {
|
||||
Thread t = new Thread(null, runnable, name);
|
||||
t.setDaemon(isDaemon);
|
||||
return t;
|
||||
}
|
||||
|
||||
/**
|
||||
* 挂起当前线程.
|
||||
*
|
||||
* @param millis 毫秒
|
||||
* @return
|
||||
*/
|
||||
public static boolean sleep(long millis) {
|
||||
if (millis > 0) {
|
||||
try {
|
||||
Thread.sleep(millis);
|
||||
} catch (InterruptedException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue