mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-01 16:32:08 +01:00
Use Executors.newSingleThreadScheduledExecutor
and remove the calls to setMaximumPoolSize() and steKeepAliveTime() since they are ineffective on Android.
This commit is contained in:
parent
39382b8b38
commit
404b90054b
2 changed files with 4 additions and 6 deletions
|
@ -33,8 +33,8 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
@ -244,7 +244,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
/**
|
/**
|
||||||
* This scheduled thread pool executor is used to remove pending callbacks.
|
* This scheduled thread pool executor is used to remove pending callbacks.
|
||||||
*/
|
*/
|
||||||
private final ScheduledThreadPoolExecutor removeCallbacksService = new ScheduledThreadPoolExecutor(1,
|
private final ScheduledExecutorService removeCallbacksService = Executors.newSingleThreadScheduledExecutor(
|
||||||
new SmackExecutorThreadFactory(connectionCounterValue, "Remove Callbacks"));
|
new SmackExecutorThreadFactory(connectionCounterValue, "Remove Callbacks"));
|
||||||
|
|
||||||
private static int concurrencyLevel = Runtime.getRuntime().availableProcessors() + 1;
|
private static int concurrencyLevel = Runtime.getRuntime().availableProcessors() + 1;
|
||||||
|
@ -333,8 +333,6 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
*/
|
*/
|
||||||
protected AbstractXMPPConnection(ConnectionConfiguration configuration) {
|
protected AbstractXMPPConnection(ConnectionConfiguration configuration) {
|
||||||
config = configuration;
|
config = configuration;
|
||||||
removeCallbacksService.setMaximumPoolSize(concurrencyLevel);
|
|
||||||
removeCallbacksService.setKeepAliveTime(THREAD_KEEP_ALIVE_SECONDS, TimeUnit.SECONDS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ConnectionConfiguration getConfiguration() {
|
protected ConnectionConfiguration getConfiguration() {
|
||||||
|
|
|
@ -21,9 +21,9 @@ import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
@ -117,7 +117,7 @@ public class PingManager extends Manager {
|
||||||
|
|
||||||
private PingManager(XMPPConnection connection) {
|
private PingManager(XMPPConnection connection) {
|
||||||
super(connection);
|
super(connection);
|
||||||
executorService = new ScheduledThreadPoolExecutor(1,
|
executorService = Executors.newSingleThreadScheduledExecutor(
|
||||||
new SmackExecutorThreadFactory(connection.getConnectionCounter(), "Ping"));
|
new SmackExecutorThreadFactory(connection.getConnectionCounter(), "Ping"));
|
||||||
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
|
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||||
sdm.addFeature(Ping.NAMESPACE);
|
sdm.addFeature(Ping.NAMESPACE);
|
||||||
|
|
Loading…
Reference in a new issue