mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-14 07:17:13 -04:00
simplified the SyncAccess interface
This commit is contained in:
parent
1e5ce0dbfb
commit
a6f792406f
@ -828,15 +828,6 @@ public class Model implements Iterable<Node>, SyncAccess {
|
|||||||
return run;
|
return run;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public <A extends ModelRun> A modifyNEx(A run) throws NodeException {
|
|
||||||
synchronized (this) {
|
|
||||||
run.run();
|
|
||||||
}
|
|
||||||
fireEvent(ModelEvent.EXTERNALCHANGE);
|
|
||||||
return run;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <A extends Runnable> A read(A run) {
|
public <A extends Runnable> A read(A run) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
|
@ -33,12 +33,6 @@ public interface SyncAccess {
|
|||||||
return run;
|
return run;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public <A extends ModelRun> A modifyNEx(A run) throws NodeException {
|
|
||||||
run.run();
|
|
||||||
return run;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <A extends Runnable> A read(A run) {
|
public <A extends Runnable> A read(A run) {
|
||||||
run.run();
|
run.run();
|
||||||
@ -56,17 +50,6 @@ public interface SyncAccess {
|
|||||||
*/
|
*/
|
||||||
<A extends Runnable> A modify(A run);
|
<A extends Runnable> A modify(A run);
|
||||||
|
|
||||||
/**
|
|
||||||
* Same as access, but catches an exception.
|
|
||||||
* The runnable is allowed to modify the model.
|
|
||||||
*
|
|
||||||
* @param run the runnable to execute
|
|
||||||
* @param <A> the type oth the runnable
|
|
||||||
* @return the given runnable. Used for chained calls
|
|
||||||
* @throws NodeException NodeException
|
|
||||||
*/
|
|
||||||
<A extends SyncAccess.ModelRun> A modifyNEx(A run) throws NodeException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calls the given runnable
|
* Calls the given runnable
|
||||||
* The runnable is NOT allowed to modify the model.
|
* The runnable is NOT allowed to modify the model.
|
||||||
@ -77,11 +60,4 @@ public interface SyncAccess {
|
|||||||
*/
|
*/
|
||||||
<A extends Runnable> A read(A run);
|
<A extends Runnable> A read(A run);
|
||||||
|
|
||||||
/**
|
|
||||||
* Like runnable but throws an exception
|
|
||||||
*/
|
|
||||||
interface ModelRun {
|
|
||||||
void run() throws NodeException;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ public class AsyncSequentialClock implements ModelStateObserverTyped {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
model.modifyNEx(() -> model.doMicroStep(false));
|
model.doMicroStep(false);
|
||||||
} catch (NodeException | RuntimeException e) {
|
} catch (NodeException | RuntimeException e) {
|
||||||
stopper.showErrorAndStopModel(Lang.get("msg_clockError"), e);
|
stopper.showErrorAndStopModel(Lang.get("msg_clockError"), e);
|
||||||
timer.cancel(false);
|
timer.cancel(false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user