diff --git a/src/main/java/net/ladenthin/bitcoinaddressfinder/AbstractProducer.java b/src/main/java/net/ladenthin/bitcoinaddressfinder/AbstractProducer.java index 03a3302..30e54d7 100644 --- a/src/main/java/net/ladenthin/bitcoinaddressfinder/AbstractProducer.java +++ b/src/main/java/net/ladenthin/bitcoinaddressfinder/AbstractProducer.java @@ -59,8 +59,7 @@ public void initProducer() { } @Override - public void releaseProducers() { - this.state = ProducerState.RELEASED; + public void releaseProducer() { } @Override @@ -167,7 +166,6 @@ void setLogger(Logger logger) { @Override public void interrupt() { - state = ProducerState.INTERRUPTED; shouldRun.set(false); } diff --git a/src/main/java/net/ladenthin/bitcoinaddressfinder/Finder.java b/src/main/java/net/ladenthin/bitcoinaddressfinder/Finder.java index 9a7c9aa..2075c68 100644 --- a/src/main/java/net/ladenthin/bitcoinaddressfinder/Finder.java +++ b/src/main/java/net/ladenthin/bitcoinaddressfinder/Finder.java @@ -28,7 +28,6 @@ import java.util.Map; import java.util.List; import java.util.Random; -import java.util.Set; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; @@ -149,7 +148,7 @@ public void interrupt() { for (Producer producer : getAllProducers()) { producer.interrupt(); producer.waitTillProducerNotRunning(); - producer.releaseProducers(); + producer.releaseProducer(); } if (consumerJava != null) { diff --git a/src/main/java/net/ladenthin/bitcoinaddressfinder/Producer.java b/src/main/java/net/ladenthin/bitcoinaddressfinder/Producer.java index 191fbfd..7ca1a1a 100644 --- a/src/main/java/net/ladenthin/bitcoinaddressfinder/Producer.java +++ b/src/main/java/net/ladenthin/bitcoinaddressfinder/Producer.java @@ -28,6 +28,11 @@ public interface Producer extends Runnable, Interruptable, ProducerStateProvider * {@link #produceKeys(int, java.util.Random)} continuously. */ void initProducer(); + + /** + * Release the producer. + */ + void releaseProducer(); /** * Create multiple keys for a specific bit length using {@link Random} and @@ -49,11 +54,6 @@ public interface Producer extends Runnable, Interruptable, ProducerStateProvider */ void processSecretBase(BigInteger secretBase); - /** - * Release the producers. - */ - void releaseProducers(); - /** * Blocks till the producer is not running anymore. */ diff --git a/src/main/java/net/ladenthin/bitcoinaddressfinder/ProducerJavaSecretsFiles.java b/src/main/java/net/ladenthin/bitcoinaddressfinder/ProducerJavaSecretsFiles.java index 4b517cb..fba05c3 100644 --- a/src/main/java/net/ladenthin/bitcoinaddressfinder/ProducerJavaSecretsFiles.java +++ b/src/main/java/net/ladenthin/bitcoinaddressfinder/ProducerJavaSecretsFiles.java @@ -89,7 +89,7 @@ private void logProgress() { } @Override - public void releaseProducers() { + public void releaseProducer() { } @Override diff --git a/src/main/java/net/ladenthin/bitcoinaddressfinder/ProducerOpenCL.java b/src/main/java/net/ladenthin/bitcoinaddressfinder/ProducerOpenCL.java index 638d0ed..d3b42de 100644 --- a/src/main/java/net/ladenthin/bitcoinaddressfinder/ProducerOpenCL.java +++ b/src/main/java/net/ladenthin/bitcoinaddressfinder/ProducerOpenCL.java @@ -109,11 +109,10 @@ int getFreeThreads() { } @Override - public void releaseProducers() { + public void releaseProducer() { if (openCLContext != null) { openCLContext.release(); openCLContext = null; - this.state = ProducerState.RELEASED; } } diff --git a/src/main/java/net/ladenthin/bitcoinaddressfinder/ProducerState.java b/src/main/java/net/ladenthin/bitcoinaddressfinder/ProducerState.java index b92da7b..47ee067 100644 --- a/src/main/java/net/ladenthin/bitcoinaddressfinder/ProducerState.java +++ b/src/main/java/net/ladenthin/bitcoinaddressfinder/ProducerState.java @@ -19,5 +19,5 @@ package net.ladenthin.bitcoinaddressfinder; public enum ProducerState { - UNINITIALIZED, INITIALIZED, RUNNING, INTERRUPTED, NOT_RUNNING, RELEASED; + UNINITIALIZED, INITIALIZED, RUNNING, NOT_RUNNING; } diff --git a/src/test/java/net/ladenthin/bitcoinaddressfinder/ProducerOpenCLTest.java b/src/test/java/net/ladenthin/bitcoinaddressfinder/ProducerOpenCLTest.java index 4af7328..2731dbb 100644 --- a/src/test/java/net/ladenthin/bitcoinaddressfinder/ProducerOpenCLTest.java +++ b/src/test/java/net/ladenthin/bitcoinaddressfinder/ProducerOpenCLTest.java @@ -77,7 +77,7 @@ public void releaseProducers_notInitialized_noExceptionThrown() throws IOExcepti ProducerOpenCL producerOpenCL = new ProducerOpenCL(cProducerOpenCL, mockConsumer, keyUtility, mockSecretFactory, new MockProducerCompletionCallback()); // act - producerOpenCL.releaseProducers(); + producerOpenCL.releaseProducer(); } @Test @@ -97,7 +97,7 @@ public void releaseProducers_initialized_noExceptionThrownAndOpenCLContextFreed( assertThat(producerOpenCL.openCLContext, notNullValue()); // act - producerOpenCL.releaseProducers(); + producerOpenCL.releaseProducer(); // assert assertThat(producerOpenCL.openCLContext, nullValue());