1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-22 14:22:05 +01:00

Change SmackExecutorthreadFactory constructor parameter to XMPPConnection

This commit is contained in:
Florian Schmaus 2015-04-22 09:45:02 +02:00
parent 7c3f4b7129
commit 17103def0b
3 changed files with 9 additions and 7 deletions

View file

@ -232,13 +232,13 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
* PacketListeners are invoked in the same order the stanzas arrived.
*/
private final ThreadPoolExecutor executorService = new ThreadPoolExecutor(1, 1, 0, TimeUnit.SECONDS,
new ArrayBlockingQueue<Runnable>(100), new SmackExecutorThreadFactory(connectionCounterValue, "Incoming Processor"));
new ArrayBlockingQueue<Runnable>(100), new SmackExecutorThreadFactory(this, "Incoming Processor"));
/**
* This scheduled thread pool executor is used to remove pending callbacks.
*/
private final ScheduledExecutorService removeCallbacksService = Executors.newSingleThreadScheduledExecutor(
new SmackExecutorThreadFactory(connectionCounterValue, "Remove Callbacks"));
new SmackExecutorThreadFactory(this, "Remove Callbacks"));
/**
* A cached thread pool executor service with custom thread factory to set meaningful names on the threads and set
@ -247,7 +247,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
private final ExecutorService cachedExecutorService = Executors.newCachedThreadPool(
// @formatter:off
new SmackExecutorThreadFactory( // threadFactory
connectionCounterValue,
this,
"Cached Executor"
)
// @formatter:on
@ -259,7 +259,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
* is the same as the order of the incoming stanzas. Therefore we use a <i>single</i> threaded executor service.
*/
private final ExecutorService singleThreadedExecutorService = Executors.newSingleThreadExecutor(new SmackExecutorThreadFactory(
getConnectionCounter(), "Single Threaded Executor"));
this, "Single Threaded Executor"));
/**
* The used host to establish the connection to

View file

@ -18,6 +18,8 @@ package org.jivesoftware.smack.util;
import java.util.concurrent.ThreadFactory;
import org.jivesoftware.smack.XMPPConnection;
/**
* SmackExecutorThreadFactory creates daemon threads with a particular name. Note that you should
* not use anonymous inner classes for thread factories in order to prevent threads from leaking.
@ -27,8 +29,8 @@ public final class SmackExecutorThreadFactory implements ThreadFactory {
private final String name;
private int count = 0;
public SmackExecutorThreadFactory(int connectionCounterValue, String name) {
this.connectionCounterValue = connectionCounterValue;
public SmackExecutorThreadFactory(XMPPConnection connection, String name) {
this.connectionCounterValue = connection.getConnectionCounter();
this.name = name;
}

View file

@ -119,7 +119,7 @@ public final class PingManager extends Manager {
private PingManager(XMPPConnection connection) {
super(connection);
executorService = Executors.newSingleThreadScheduledExecutor(
new SmackExecutorThreadFactory(connection.getConnectionCounter(), "Ping"));
new SmackExecutorThreadFactory(connection, "Ping"));
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
sdm.addFeature(Ping.NAMESPACE);