-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
116 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...src/main/java/com/ishland/c2me/base/common/scheduler/AbstractPosAwarePrioritizedTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.ishland.c2me.base.common.scheduler; | ||
|
||
import com.ishland.flowsched.executor.Task; | ||
import it.unimi.dsi.fastutil.objects.ReferenceArrayList; | ||
|
||
import java.util.Objects; | ||
|
||
public abstract class AbstractPosAwarePrioritizedTask implements Task { | ||
|
||
protected final ReferenceArrayList<Runnable> postExec = new ReferenceArrayList<>(4); | ||
private final long pos; | ||
private int priority = Integer.MAX_VALUE; | ||
|
||
public AbstractPosAwarePrioritizedTask(long pos) { | ||
this.pos = pos; | ||
} | ||
|
||
@Override | ||
public int priority() { | ||
return this.priority; | ||
} | ||
|
||
public void setPriority(int priority) { | ||
this.priority = priority; | ||
} | ||
|
||
public long getPos() { | ||
return this.pos; | ||
} | ||
|
||
public void addPostExec(Runnable runnable) { | ||
synchronized (this.postExec) { | ||
postExec.add(Objects.requireNonNull(runnable)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
c2me-base/src/main/java/com/ishland/c2me/base/common/scheduler/WrappingTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.ishland.c2me.base.common.scheduler; | ||
|
||
import com.ishland.flowsched.executor.LockToken; | ||
|
||
import java.util.Objects; | ||
|
||
public class WrappingTask extends AbstractPosAwarePrioritizedTask { | ||
|
||
private static final LockToken[] EMPTY_LOCK_TOKENS = new LockToken[0]; | ||
|
||
private final Runnable wrapped; | ||
|
||
public WrappingTask(long pos, Runnable wrapped) { | ||
super(pos); | ||
this.wrapped = Objects.requireNonNull(wrapped); | ||
} | ||
|
||
@Override | ||
public void run() { | ||
try { | ||
wrapped.run(); | ||
} finally { | ||
for (Runnable runnable : this.postExec) { | ||
try { | ||
runnable.run(); | ||
} catch (Throwable t1) { | ||
t1.printStackTrace(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void propagateException(Throwable t) { | ||
t.printStackTrace(); | ||
} | ||
|
||
@Override | ||
public LockToken[] lockTokens() { | ||
return EMPTY_LOCK_TOKENS; | ||
} | ||
} |
72 changes: 0 additions & 72 deletions
72
c2me-base/src/main/java/com/ishland/c2me/base/common/util/AsyncCombinedLock.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.