From 7c2545cdc28f0eecfff028250a7171dc29fa06e7 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Tue, 28 Apr 2020 10:10:36 +0200 Subject: [PATCH] common/include/eoskeygen/key_search.hpp: adding abort() --- common/include/eoskeygen/key_search.hpp | 6 ++++++ common/src/key_search.cpp | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/common/include/eoskeygen/key_search.hpp b/common/include/eoskeygen/key_search.hpp index eb358da..3e3975a 100644 --- a/common/include/eoskeygen/key_search.hpp +++ b/common/include/eoskeygen/key_search.hpp @@ -71,6 +71,12 @@ public : void setThreadCount(size_t num); #endif /* EOSIOKEYGEN_HAVE_THREADS */ + // Aborts find() operation if started. + // This is useful for multithreaded code (like GUI application) + // If find() is started as a seperate thread. This method could be called + // from the gui thread if the user presses "cancel" button. + void abort(); + // Perform a search. void find(size_t num_results); diff --git a/common/src/key_search.cpp b/common/src/key_search.cpp index 68803a9..506ee84 100644 --- a/common/src/key_search.cpp +++ b/common/src/key_search.cpp @@ -83,6 +83,12 @@ void KeySearch::_search_linear() } } +void KeySearch::abort() +{ + // exit find() operation by setting m_max to zero. + m_max = 0; +} + void KeySearch::find(size_t num_results) { m_count = 0;