mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-29 09:42:06 +01:00
Make XMPPConnection.schedule() protected
This method was never intended to be part of the public API. It's also critical that the given Runnables complete within a reasonable time frame so that they don't block following ones.
This commit is contained in:
parent
1302dbe9cb
commit
a19181ce04
3 changed files with 8 additions and 2 deletions
|
@ -17,6 +17,8 @@
|
||||||
package org.jivesoftware.smack;
|
package org.jivesoftware.smack;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public abstract class Manager {
|
public abstract class Manager {
|
||||||
|
|
||||||
|
@ -29,4 +31,8 @@ public abstract class Manager {
|
||||||
protected final XMPPConnection connection() {
|
protected final XMPPConnection connection() {
|
||||||
return weakConnection.get();
|
return weakConnection.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
|
||||||
|
return connection().schedule(command, delay, unit);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1275,7 +1275,7 @@ public abstract class XMPPConnection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
|
protected ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
|
||||||
return executorService.schedule(command, delay, unit);
|
return executorService.schedule(command, delay, unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -308,7 +308,7 @@ public class PingManager extends Manager {
|
||||||
int nextPingIn = pingInterval - delta;
|
int nextPingIn = pingInterval - delta;
|
||||||
LOGGER.fine("Scheduling ServerPingTask in " + nextPingIn + " seconds (pingInterval="
|
LOGGER.fine("Scheduling ServerPingTask in " + nextPingIn + " seconds (pingInterval="
|
||||||
+ pingInterval + ", delta=" + delta + ")");
|
+ pingInterval + ", delta=" + delta + ")");
|
||||||
nextAutomaticPing = connection().schedule(pingServerRunnable, pingInterval, TimeUnit.SECONDS);
|
nextAutomaticPing = schedule(pingServerRunnable, pingInterval, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue