Skip to content

Commit 883c9e7

Browse files
authored
Merge pull request #72 from cgkantidis/threadpool
Add a threadpool and run the comparison of each file with all files a…
2 parents 8b6c922 + b6759f0 commit 883c9e7

15 files changed

+197
-160
lines changed

CMakeLists.txt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@ FetchContent_Declare(
2222
GIT_SHALLOW 1
2323
OVERRIDE_FIND_PACKAGE
2424
)
25-
FetchContent_MakeAvailable(nlohmann_json)
25+
FetchContent_Declare(
26+
thread_pool
27+
GIT_REPOSITORY https://github.com/bshoshany/thread-pool.git
28+
GIT_TAG v5.0.0
29+
GIT_SHALLOW 1
30+
OVERRIDE_FIND_PACKAGE
31+
)
32+
FetchContent_MakeAvailable(nlohmann_json thread_pool)
2633

2734
add_executable(duplo ${SOURCES})
2835

@@ -34,7 +41,10 @@ set_target_properties(duplo PROPERTIES
3441
target_compile_definitions(duplo PRIVATE DUPLO_VERSION=${DUPLO_VERSION})
3542
target_include_directories(duplo PRIVATE src/include/)
3643
find_package(nlohmann_json 3.11.3 REQUIRED)
37-
target_link_libraries(duplo PRIVATE nlohmann_json::nlohmann_json)
44+
add_library(thread_pool INTERFACE)
45+
target_include_directories(thread_pool INTERFACE ${thread_pool_SOURCE_DIR}/include)
46+
find_package(Threads REQUIRED)
47+
target_link_libraries(duplo PRIVATE nlohmann_json::nlohmann_json thread_pool Threads::Threads)
3848

3949
if(NOT MSVC)
4050
target_compile_options(duplo PRIVATE -Wall -Wextra -pedantic -Werror)

src/ConsoleExporter.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "Block.h"
12
#include "ConsoleExporter.h"
23
#include "FileExporter.h"
34

@@ -16,7 +17,8 @@ void ConsoleExporter::WriteFooter(
1617
const Options& options,
1718
int files,
1819
long locsTotal,
19-
const ProcessResult& processResult) {
20+
unsigned tot_dup_blocks,
21+
unsigned tot_dup_lines) {
2022
Out()
2123
<< "Configuration:"
2224
<< std::endl
@@ -42,10 +44,10 @@ void ConsoleExporter::WriteFooter(
4244
<< locsTotal
4345
<< std::endl
4446
<< " Duplicate lines of code: "
45-
<< processResult.DuplicateLines()
47+
<< tot_dup_lines
4648
<< std::endl
4749
<< " Total "
48-
<< processResult.Blocks()
50+
<< tot_dup_blocks
4951
<< " duplicate block(s) found."
5052
<< std::endl
5153
<< std::endl;

0 commit comments

Comments
 (0)