mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-03-10 09:20:04 +01:00
Threading: use ExecutorService
for THREAD_POOL
Guava's `ListeningExecutorService` is no longer needed. Update type of private executor in PaymentSession to match.
This commit is contained in:
parent
c3395098fe
commit
d05d44c8c3
2 changed files with 8 additions and 12 deletions
|
@ -17,7 +17,6 @@
|
||||||
package org.bitcoinj.protocols.payments;
|
package org.bitcoinj.protocols.payments;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.util.concurrent.ListeningExecutorService;
|
|
||||||
import com.google.protobuf.InvalidProtocolBufferException;
|
import com.google.protobuf.InvalidProtocolBufferException;
|
||||||
import org.bitcoin.protocols.payments.Protos;
|
import org.bitcoin.protocols.payments.Protos;
|
||||||
import org.bitcoinj.base.Address;
|
import org.bitcoinj.base.Address;
|
||||||
|
@ -50,6 +49,7 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Provides a standard implementation of the Payment Protocol (BIP 0070)</p>
|
* <p>Provides a standard implementation of the Payment Protocol (BIP 0070)</p>
|
||||||
|
@ -79,7 +79,7 @@ import java.util.concurrent.CompletableFuture;
|
||||||
* @see <a href="https://github.com/bitcoin/bips/blob/master/bip-0070.mediawiki">BIP 0070</a>
|
* @see <a href="https://github.com/bitcoin/bips/blob/master/bip-0070.mediawiki">BIP 0070</a>
|
||||||
*/
|
*/
|
||||||
public class PaymentSession {
|
public class PaymentSession {
|
||||||
private final static ListeningExecutorService executor = Threading.THREAD_POOL;
|
private final static ExecutorService executor = Threading.THREAD_POOL;
|
||||||
private NetworkParameters params;
|
private NetworkParameters params;
|
||||||
private Protos.PaymentRequest paymentRequest;
|
private Protos.PaymentRequest paymentRequest;
|
||||||
private Protos.PaymentDetails paymentDetails;
|
private Protos.PaymentDetails paymentDetails;
|
||||||
|
|
|
@ -17,8 +17,6 @@
|
||||||
package org.bitcoinj.utils;
|
package org.bitcoinj.utils;
|
||||||
|
|
||||||
import com.google.common.util.concurrent.CycleDetectingLockFactory;
|
import com.google.common.util.concurrent.CycleDetectingLockFactory;
|
||||||
import com.google.common.util.concurrent.ListeningExecutorService;
|
|
||||||
import com.google.common.util.concurrent.MoreExecutors;
|
|
||||||
import com.google.common.util.concurrent.Uninterruptibles;
|
import com.google.common.util.concurrent.Uninterruptibles;
|
||||||
import org.bitcoinj.base.internal.PlatformUtils;
|
import org.bitcoinj.base.internal.PlatformUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -185,12 +183,10 @@ public class Threading {
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/** A caching thread pool that creates daemon threads, which won't keep the JVM alive waiting for more work. */
|
/** A caching thread pool that creates daemon threads, which won't keep the JVM alive waiting for more work. */
|
||||||
public static ListeningExecutorService THREAD_POOL = MoreExecutors.listeningDecorator(
|
public static ExecutorService THREAD_POOL = Executors.newCachedThreadPool(r -> {
|
||||||
Executors.newCachedThreadPool(r -> {
|
|
||||||
Thread t = new Thread(r);
|
Thread t = new Thread(r);
|
||||||
t.setName("Threading.THREAD_POOL worker");
|
t.setName("Threading.THREAD_POOL worker");
|
||||||
t.setDaemon(true);
|
t.setDaemon(true);
|
||||||
return t;
|
return t;
|
||||||
})
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue