Use a work stealing pool
This commit is contained in:
parent
a333659741
commit
bb3d822988
|
@ -12,7 +12,7 @@ public class Actor implements Executor {
|
|||
private final static ThreadLocal<Actor> _currentActor = new ThreadLocal<>();
|
||||
private final static AtomicLong _count = new AtomicLong(0);
|
||||
private final static AtomicLong _actorId = new AtomicLong(0);
|
||||
protected final static ExecutorService _executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
|
||||
protected final static ExecutorService _executor = Executors.newWorkStealingPool();
|
||||
protected final static ScheduledExecutorService _scheduledExecutor = Executors.newScheduledThreadPool(Runtime.getRuntime().availableProcessors());
|
||||
|
||||
private final String _name;
|
||||
|
|
|
@ -5,13 +5,15 @@ import org.syndicate_lang.actors.Actor;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static java.lang.Integer.parseInt;
|
||||
|
||||
public class Main implements IForwarder {
|
||||
|
||||
private List<IForwarder> _actors;
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
Actor.convenientLogging();
|
||||
Actor.forObject(new Main(1000000, 10)).syncVoid(Main::boot).await();
|
||||
Actor.forObject(new Main(parseInt(args[0]), parseInt(args[1]))).syncVoid(Main::boot).await();
|
||||
Actor.awaitAll();
|
||||
}
|
||||
|
||||
|
@ -26,6 +28,7 @@ public class Main implements IForwarder {
|
|||
}
|
||||
|
||||
public void boot() {
|
||||
Actor.log().info("Available processors: " + Runtime.getRuntime().availableProcessors());
|
||||
this._actors = new ArrayList<>();
|
||||
IForwarder me = Actor.ref(this).asyncProxy(IForwarder.class);
|
||||
for (int i = 0; i < _nActors; i++) {
|
||||
|
|
Loading…
Reference in New Issue