use of org.apollo.game.sync.task.PhasedSynchronizationTask in project apollo by apollo-rsps.
the class ParallelClientSynchronizer method synchronize.
@Override
public void synchronize(MobRepository<Player> players, MobRepository<Npc> npcs) {
int playerCount = players.size();
int npcCount = npcs.size();
Map<RegionCoordinates, Set<RegionUpdateMessage>> encodes = new ConcurrentHashMap<>();
Map<RegionCoordinates, Set<RegionUpdateMessage>> updates = new ConcurrentHashMap<>();
phaser.bulkRegister(playerCount);
for (Player player : players) {
SynchronizationTask task = new PrePlayerSynchronizationTask(player, encodes, updates);
executor.submit(new PhasedSynchronizationTask(phaser, task));
}
phaser.arriveAndAwaitAdvance();
phaser.bulkRegister(npcCount);
for (Npc npc : npcs) {
SynchronizationTask task = new PreNpcSynchronizationTask(npc);
executor.submit(new PhasedSynchronizationTask(phaser, task));
}
phaser.arriveAndAwaitAdvance();
phaser.bulkRegister(playerCount);
for (Player player : players) {
SynchronizationTask task = new PlayerSynchronizationTask(player);
executor.submit(new PhasedSynchronizationTask(phaser, task));
}
phaser.arriveAndAwaitAdvance();
phaser.bulkRegister(playerCount);
for (Player player : players) {
SynchronizationTask task = new NpcSynchronizationTask(player);
executor.submit(new PhasedSynchronizationTask(phaser, task));
}
phaser.arriveAndAwaitAdvance();
phaser.bulkRegister(playerCount);
for (Player player : players) {
SynchronizationTask task = new PostPlayerSynchronizationTask(player);
executor.submit(new PhasedSynchronizationTask(phaser, task));
}
phaser.arriveAndAwaitAdvance();
phaser.bulkRegister(npcCount);
for (Npc npc : npcs) {
SynchronizationTask task = new PostNpcSynchronizationTask(npc);
executor.submit(new PhasedSynchronizationTask(phaser, task));
}
phaser.arriveAndAwaitAdvance();
}
Aggregations