mirror of
https://gitee.com/jd-platform-opensource/asyncTool.git
synced 2026-03-22 04:27:15 +08:00
fix:最后一个任务不能执行的问题
This commit is contained in:
@@ -362,7 +362,9 @@ public abstract class WorkerWrapper<T, V> {
|
||||
wrapperStrategy.judgeAction(getDependWrappers(), this, fromWrapper);
|
||||
switch (judge.getDependenceAction()) {
|
||||
case TAKE_REST:
|
||||
System.out.println("TAKE_REST\t"+id+"\t"+fromWrapper.id);
|
||||
//FIXME 等待200毫秒重新投入线程池,主要为了调起最后一个任务
|
||||
Thread.sleep(200L);
|
||||
executorService.submit(() -> this.work(executorService, fromWrapper, remainTime, group));
|
||||
return;
|
||||
case FAST_FAIL:
|
||||
if (setState(state, STARTED, ERROR)) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.jd.platform.async.wrapper.strategy.depend;
|
||||
|
||||
import com.jd.platform.async.exception.SkippedException;
|
||||
import com.jd.platform.async.worker.ResultState;
|
||||
import com.jd.platform.async.worker.WorkResult;
|
||||
import com.jd.platform.async.wrapper.WorkerWrapper;
|
||||
@@ -111,7 +110,6 @@ public interface DependenceStrategy {
|
||||
}
|
||||
}
|
||||
if (hasWaiting) {
|
||||
System.out.println(Thread.currentThread().getName()+"\thasWaiting\t"+thisWrapper.getId()+"\t"+fromWrapper.getId());
|
||||
return DependenceAction.TAKE_REST.emptyProperty();
|
||||
}
|
||||
return DependenceAction.START_WORK.emptyProperty();
|
||||
|
||||
@@ -15,14 +15,17 @@ class Case1 {
|
||||
return WorkerWrapper.<String, String>builder()
|
||||
.id(id)
|
||||
.worker((param, allWrappers) -> {
|
||||
System.out.println("wrapper(id=" + id + ") is working");
|
||||
try {
|
||||
if ("F".equals(id)) {
|
||||
Thread.sleep(50);
|
||||
System.out.println("wrapper(id=" + id + ") is working");
|
||||
Thread.sleep(5000);
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if ("F".equals(id)) {
|
||||
System.out.println("wrapper(id=" + id + ") is worki444ng");
|
||||
}
|
||||
return id;
|
||||
});
|
||||
}
|
||||
@@ -44,7 +47,7 @@ class Case1 {
|
||||
)
|
||||
.build();
|
||||
try {
|
||||
Async.work(10000, a, d).awaitFinish();
|
||||
Async.work(1000, a, d).awaitFinish();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -315,6 +315,7 @@ public class HashedWheelTimer extends AbstractWheelTimer {
|
||||
startTimeInitialized.countDown();
|
||||
|
||||
do {
|
||||
//TODO 时间轮这里结束不了任务
|
||||
final long deadline = waitForNextTick();
|
||||
if (deadline > 0) {
|
||||
int idx = (int) (tick & mask);
|
||||
|
||||
Reference in New Issue
Block a user