Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SMAC
AMAK
Java
core
Commits
521cb137
Commit
521cb137
authored
3 years ago
by
unknown
Browse files
Options
Downloads
Patches
Plain Diff
Error correction
parent
85a33706
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/mas/implementation/base/schedulers/TwoDCycling.java
+34
-1
34 additions, 1 deletion
src/mas/implementation/base/schedulers/TwoDCycling.java
with
34 additions
and
1 deletion
src/mas/implementation/base/schedulers/TwoDCycling.java
+
34
−
1
View file @
521cb137
...
@@ -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
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment