Skip to content

Commit

Permalink
use virtual threads for ag scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
jomifred committed Oct 4, 2024
1 parent f222fcd commit 9dc66fd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions jason-interpreter/src/main/java/jason/asSemantics/Agent.java
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,9 @@ public static synchronized ScheduledExecutorService getScheduler() {
try {
n = Integer.parseInt( Config.get().get(Config.NB_TH_SCH).toString() );
} catch (Exception e) {
n = 2;
n = 3;
}
scheduler = Executors.newScheduledThreadPool(n);
scheduler = Executors.newScheduledThreadPool(n, Thread.ofVirtual().factory());
}
return scheduler;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void timeout(TransitionSystem ts, String intentionKey) { // called back w
*/
public abstract class ConcurrentInternalAction implements InternalAction {

private static AtomicInteger actcount = new AtomicInteger(0);
private static final AtomicInteger actCount = new AtomicInteger(0);

public boolean canBeUsedInContext() {
return false;
Expand Down Expand Up @@ -88,7 +88,7 @@ public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Excep
* @return the final key used to store the intention in PI, this key is used the resume the intention
*/
public String suspendInt(final TransitionSystem ts, String basekey, int timeout) {
final String key = basekey + "/" + (actcount.incrementAndGet());
final String key = basekey + "/" + (actCount.incrementAndGet());
final Circumstance C = ts.getC();
Intention i = C.getSelectedIntention();
i.setSuspended(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import jason.asSyntax.Literal;
import jason.asSyntax.Term;

import java.io.Serial;
import java.io.Serializable;

/**
Expand All @@ -16,6 +17,7 @@
*/
public class DefaultInternalAction implements InternalAction, Serializable {

@Serial
private static final long serialVersionUID = 1L;

public boolean suspendIntention() {
Expand Down

0 comments on commit 9dc66fd

Please sign in to comment.