Skip to content
Snippets Groups Projects
Commit 521cb137 authored by unknown's avatar unknown
Browse files

Error correction

parent 85a33706
No related branches found
No related tags found
No related merge requests found
...@@ -2,19 +2,29 @@ package mas.implementation.base.schedulers; ...@@ -2,19 +2,29 @@ package mas.implementation.base.schedulers;
import mas.core.Cyclable; import mas.core.Cyclable;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.function.Consumer;
public class TwoDCycling extends FairCycling{ public class TwoDCycling extends FairCycling{
/** /**
* The state of the scheduler {@link State} * The state of the scheduler {@link State}
*/ */
protected State state = State.PENDING_START; private State state = State.PENDING_START;
/**
* Method that is called when the scheduler stops
*/
private Consumer<TwoDCycling> onStop;
/** /**
* The methods called when the speed is changed. Useful to change the value of * The methods called when the speed is changed. Useful to change the value of
* the GUI slider of * the GUI slider of
*/ */
private List<Consumer<TwoDCycling>> onChange = new ArrayList<>();
public enum State { public enum State {
/** /**
...@@ -36,6 +46,29 @@ public class TwoDCycling extends FairCycling{ ...@@ -36,6 +46,29 @@ public class TwoDCycling extends FairCycling{
super(_cyclables); super(_cyclables);
} }
/**
* Set the method that must be executed when the system is stopped
*
* @param _onStop
* Consumer method
*/
public final void setOnStop(Consumer<TwoDCycling> _onStop) {
this.onStop = _onStop;
}
/**
* Add a method that must be executed when the scheduler speed is changed
*
* @param _onChange
* Consumer method
*/
public final void addOnChange(Consumer<TwoDCycling> _onChange) {
synchronized (onChange) {
this.onChange.add(_onChange);
}
}
public void doOneCycle() { public void doOneCycle() {
executor.execute(() -> { executor.execute(() -> {
step(); step();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment