mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 22:32:06 +01:00
Change SmackExecutorthreadFactory constructor parameter to XMPPConnection
This commit is contained in:
parent
7c3f4b7129
commit
17103def0b
3 changed files with 9 additions and 7 deletions
|
@ -232,13 +232,13 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
* PacketListeners are invoked in the same order the stanzas arrived.
|
* PacketListeners are invoked in the same order the stanzas arrived.
|
||||||
*/
|
*/
|
||||||
private final ThreadPoolExecutor executorService = new ThreadPoolExecutor(1, 1, 0, TimeUnit.SECONDS,
|
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.
|
* This scheduled thread pool executor is used to remove pending callbacks.
|
||||||
*/
|
*/
|
||||||
private final ScheduledExecutorService removeCallbacksService = Executors.newSingleThreadScheduledExecutor(
|
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
|
* 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(
|
private final ExecutorService cachedExecutorService = Executors.newCachedThreadPool(
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
new SmackExecutorThreadFactory( // threadFactory
|
new SmackExecutorThreadFactory( // threadFactory
|
||||||
connectionCounterValue,
|
this,
|
||||||
"Cached Executor"
|
"Cached Executor"
|
||||||
)
|
)
|
||||||
// @formatter:on
|
// @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.
|
* 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(
|
private final ExecutorService singleThreadedExecutorService = Executors.newSingleThreadExecutor(new SmackExecutorThreadFactory(
|
||||||
getConnectionCounter(), "Single Threaded Executor"));
|
this, "Single Threaded Executor"));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The used host to establish the connection to
|
* The used host to establish the connection to
|
||||||
|
|
|
@ -18,6 +18,8 @@ package org.jivesoftware.smack.util;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SmackExecutorThreadFactory creates daemon threads with a particular name. Note that you should
|
* 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.
|
* 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 final String name;
|
||||||
private int count = 0;
|
private int count = 0;
|
||||||
|
|
||||||
public SmackExecutorThreadFactory(int connectionCounterValue, String name) {
|
public SmackExecutorThreadFactory(XMPPConnection connection, String name) {
|
||||||
this.connectionCounterValue = connectionCounterValue;
|
this.connectionCounterValue = connection.getConnectionCounter();
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,7 @@ public final class PingManager extends Manager {
|
||||||
private PingManager(XMPPConnection connection) {
|
private PingManager(XMPPConnection connection) {
|
||||||
super(connection);
|
super(connection);
|
||||||
executorService = Executors.newSingleThreadScheduledExecutor(
|
executorService = Executors.newSingleThreadScheduledExecutor(
|
||||||
new SmackExecutorThreadFactory(connection.getConnectionCounter(), "Ping"));
|
new SmackExecutorThreadFactory(connection, "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