simplified the SyncAccess interface

This commit is contained in:
hneemann 2020-04-15 18:55:02 +02:00
parent 1e5ce0dbfb
commit a6f792406f
3 changed files with 1 additions and 34 deletions

View File

@ -828,15 +828,6 @@ public class Model implements Iterable<Node>, SyncAccess {
return run;
}
@Override
public <A extends ModelRun> A modifyNEx(A run) throws NodeException {
synchronized (this) {
run.run();
}
fireEvent(ModelEvent.EXTERNALCHANGE);
return run;
}
@Override
public <A extends Runnable> A read(A run) {
synchronized (this) {

View File

@ -33,12 +33,6 @@ public interface SyncAccess {
return run;
}
@Override
public <A extends ModelRun> A modifyNEx(A run) throws NodeException {
run.run();
return run;
}
@Override
public <A extends Runnable> A read(A run) {
run.run();
@ -56,17 +50,6 @@ public interface SyncAccess {
*/
<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
* The runnable is NOT allowed to modify the model.
@ -77,11 +60,4 @@ public interface SyncAccess {
*/
<A extends Runnable> A read(A run);
/**
* Like runnable but throws an exception
*/
interface ModelRun {
void run() throws NodeException;
}
}

View File

@ -77,7 +77,7 @@ public class AsyncSequentialClock implements ModelStateObserverTyped {
@Override
public void run() {
try {
model.modifyNEx(() -> model.doMicroStep(false));
model.doMicroStep(false);
} catch (NodeException | RuntimeException e) {
stopper.showErrorAndStopModel(Lang.get("msg_clockError"), e);
timer.cancel(false);