ItEr57S15RecalculosConexionEscenarios: Add class to execute different code depending if it's reentring or not
This commit is contained in:
parent
267d9afda0
commit
3bfab5d143
1 changed files with 24 additions and 0 deletions
|
|
@ -654,4 +654,28 @@ public class GanttDiagramGraph implements ICriticalPathCalculable<Task> {
|
|||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
interface IReentranceCases {
|
||||
public void ifNewEntrance();
|
||||
}
|
||||
|
||||
class ReentranceGuard {
|
||||
private final ThreadLocal<Boolean> inside = new ThreadLocal<Boolean>() {
|
||||
protected Boolean initialValue() {
|
||||
return false;
|
||||
};
|
||||
};
|
||||
|
||||
public void entranceRequested(IReentranceCases reentranceCases) {
|
||||
if (inside.get()) {
|
||||
return;
|
||||
}
|
||||
inside.set(true);
|
||||
try {
|
||||
reentranceCases.ifNewEntrance();
|
||||
} finally {
|
||||
inside.set(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue