42 lines
1.1 KiB
Java
42 lines
1.1 KiB
Java
package impl;
|
|
|
|
import java.util.concurrent.ExecutionException;
|
|
import java.util.concurrent.Future;
|
|
|
|
import interfaces.AlgoDiffusion;
|
|
import interfaces.ObserverDeCapteurAsync;
|
|
|
|
public class DiffusionEpoque implements AlgoDiffusion {
|
|
|
|
public CapteurImpl capteur;
|
|
|
|
@Override
|
|
public void configure() {
|
|
// TODO Auto-generated method stub
|
|
throw new UnsupportedOperationException("Unimplemented method 'configure'");
|
|
}
|
|
|
|
@Override
|
|
public void execute() {
|
|
this.capteur.lock2();
|
|
System.out.println("execute");
|
|
Future<?>[] l = new Future<?>[capteur.observers.size()];
|
|
int i = 0;
|
|
for (ObserverDeCapteurAsync canal : capteur.observers) {
|
|
Future<?> f = canal.update();
|
|
l[i] = f;
|
|
i++;
|
|
}
|
|
|
|
for (Future<?> f : l) { //attend que les autres soient résolus //TODO
|
|
try {
|
|
f.get();
|
|
} catch (InterruptedException | ExecutionException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
this.capteur.unlock2();
|
|
//this.capteur.unlock();
|
|
}
|
|
}
|