1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-26 12:37:58 +01:00

Use Executors.newSingleThreadScheduledExecutor

and remove the calls to setMaximumPoolSize() and steKeepAliveTime()
since they are ineffective on Android.
This commit is contained in:
Florian Schmaus 2015-02-25 16:14:16 +01:00
parent 39382b8b38
commit 404b90054b
2 changed files with 4 additions and 6 deletions

View file

@ -33,8 +33,8 @@ import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
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.
*/
private final ScheduledThreadPoolExecutor removeCallbacksService = new ScheduledThreadPoolExecutor(1,
private final ScheduledExecutorService removeCallbacksService = Executors.newSingleThreadScheduledExecutor(
new SmackExecutorThreadFactory(connectionCounterValue, "Remove Callbacks"));
private static int concurrencyLevel = Runtime.getRuntime().availableProcessors() + 1;
@ -333,8 +333,6 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
*/
protected AbstractXMPPConnection(ConnectionConfiguration configuration) {
config = configuration;
removeCallbacksService.setMaximumPoolSize(concurrencyLevel);
removeCallbacksService.setKeepAliveTime(THREAD_KEEP_ALIVE_SECONDS, TimeUnit.SECONDS);
}
protected ConnectionConfiguration getConfiguration() {

View file

@ -21,9 +21,9 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.WeakHashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -117,7 +117,7 @@ public class PingManager extends Manager {
private PingManager(XMPPConnection connection) {
super(connection);
executorService = new ScheduledThreadPoolExecutor(1,
executorService = Executors.newSingleThreadScheduledExecutor(
new SmackExecutorThreadFactory(connection.getConnectionCounter(), "Ping"));
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
sdm.addFeature(Ping.NAMESPACE);