diff --git a/CMakeLists.txt b/CMakeLists.txt index 0222841..863826a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,7 @@ if (USE_THREADS) if (Threads_FOUND) # Add preprocessor flag add_definitions( "-DHAVE_THREADS=1" ) - set (PROGRAM_SOURCE ${PROGRAM_SOURCE} src/key_search_nt.cpp) + set (PROGRAM_SOURCE ${PROGRAM_SOURCE} src/key_search_mt.cpp) endif (Threads_FOUND) endif (USE_THREADS) diff --git a/src/key_search.cpp b/src/key_search.cpp index cc2faf6..4201588 100644 --- a/src/key_search.cpp +++ b/src/key_search.cpp @@ -5,7 +5,7 @@ #include "key_search_helpers.h" #include "key_search.h" -void key_search_n(const strlist_t& word_list, size_t n) { +void key_search(const strlist_t& word_list, size_t n) { size_t count = 0; struct ec_keypair pair; diff --git a/src/key_search.h b/src/key_search.h index f6a77e2..9676053 100644 --- a/src/key_search.h +++ b/src/key_search.h @@ -27,10 +27,10 @@ #include "string.h" #include "ec.h" -void key_search_n(const strlist_t& word_list, size_t n); +void key_search(const strlist_t& word_list, size_t n); #ifdef HAVE_THREADS -void key_search_nt(const strlist_t& word_list, size_t n, size_t n_threads = 0); +void key_search_mt(const strlist_t& word_list, size_t n, size_t n_threads = 0); #endif /* HAVE_THREADS */ #endif /* KEY_SEARCH_H */ diff --git a/src/key_search_nt.cpp b/src/key_search_mt.cpp similarity index 86% rename from src/key_search_nt.cpp rename to src/key_search_mt.cpp index c1b1b23..bfb2584 100644 --- a/src/key_search_nt.cpp +++ b/src/key_search_mt.cpp @@ -15,7 +15,7 @@ unsigned int g_count; std::mutex g_count_mtx; // Thread process. -static void thr_proc(const strlist_t& word_list) { +static void _mt_search(const strlist_t& word_list) { struct ec_keypair pair; @@ -43,14 +43,14 @@ static void thr_proc(const strlist_t& word_list) { } } -void key_search_nt(const strlist_t& word_list, size_t n, size_t n_threads) { +void key_search_mt(const strlist_t& word_list, size_t n, size_t n_threads) { std::vector t; // Not enough threads passed in by caller. if (n_threads < 2) { // Just use linear function. - key_search_n(word_list, n); + key_search(word_list, n); return; } @@ -62,11 +62,11 @@ void key_search_nt(const strlist_t& word_list, size_t n, size_t n_threads) { // Launch them. for(int i = 0; i < t.size(); i++) { - t[i] = std::thread(thr_proc, word_list); + t[i] = std::thread(_mt_search, word_list); } // Use main thread for 1 search - thr_proc(word_list); + _mt_search(word_list); // Wait for all threads to compelete. for(int i = 0; i < t.size(); i++) { diff --git a/src/main.cpp b/src/main.cpp index d9f2ab3..dec65e9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -43,12 +43,12 @@ } \ } #define n_thread_outp << ", Using: " << n_threads << " threads" -#define call_search key_search_nt(words, n, n_threads) +#define call_search key_search_mt(words, n, n_threads) #else #define n_thread_decl #define n_thread_argv #define n_thread_outp -#define call_search key_search_n(words, n) +#define call_search key_search(words, n) #endif /* HAVE_THREADS */ void cmd_search(int argc, char **argv) {