mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 19:29:06 +01:00
Address review feedback.
This commit is contained in:
@@ -36,7 +36,7 @@ interface TorReachabilityMonitor {
|
||||
* Observers are removed after being called, or when the monitor is
|
||||
* {@link #destroy() destroyed}.
|
||||
*/
|
||||
void addObserver(TorReachabilityObserver o);
|
||||
void addOneShotObserver(TorReachabilityObserver o);
|
||||
|
||||
interface TorReachabilityObserver {
|
||||
|
||||
|
||||
@@ -70,13 +70,14 @@ class TorReachabilityMonitorImpl
|
||||
eventBus.removeListener(this);
|
||||
synchronized (lock) {
|
||||
destroyed = true;
|
||||
onTorInactive();
|
||||
if (task != null) task.cancel();
|
||||
task = null;
|
||||
observers.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addObserver(TorReachabilityObserver o) {
|
||||
public void addOneShotObserver(TorReachabilityObserver o) {
|
||||
boolean callNow = false;
|
||||
synchronized (lock) {
|
||||
if (destroyed) return;
|
||||
|
||||
@@ -156,7 +156,7 @@ public class TorReachabilityMonitorImplTest extends BrambleMockTestCase {
|
||||
monitor.start();
|
||||
|
||||
// Register an observer
|
||||
monitor.addObserver(observer);
|
||||
monitor.addOneShotObserver(observer);
|
||||
|
||||
// When Tor becomes active, a task should be scheduled
|
||||
AtomicReference<Runnable> runnable = new AtomicReference<>(null);
|
||||
@@ -202,7 +202,7 @@ public class TorReachabilityMonitorImplTest extends BrambleMockTestCase {
|
||||
monitor.start();
|
||||
|
||||
// Register an observer
|
||||
monitor.addObserver(observer);
|
||||
monitor.addOneShotObserver(observer);
|
||||
|
||||
// When the task runs, the observer should be called
|
||||
context.checking(new Expectations() {{
|
||||
@@ -241,6 +241,6 @@ public class TorReachabilityMonitorImplTest extends BrambleMockTestCase {
|
||||
oneOf(observer).onTorReachable();
|
||||
}});
|
||||
|
||||
monitor.addObserver(observer);
|
||||
monitor.addOneShotObserver(observer);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user