Address review feedback.

This commit is contained in:
akwizgran
2022-06-03 17:09:51 +01:00
parent 2672d82a40
commit 5517ac14ed
3 changed files with 7 additions and 6 deletions

View File

@@ -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 {

View File

@@ -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;