├── .clang-format ├── .clang-tidy ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── failed-tests.md │ └── feature_request.md └── pull_request_template.md ├── .gitignore ├── .vscode-linux ├── c_cpp_properties.json ├── launch.json └── tasks.json ├── .vscode-macos ├── c_cpp_properties.json ├── launch.json └── tasks.json ├── .vscode-windows ├── c_cpp_properties.json ├── launch.json └── tasks.json ├── CHANGELOG.md ├── CITATION.bib ├── CITATION.cff ├── LICENSE.txt ├── README.md ├── compile_cpp.yaml ├── include └── BS_thread_pool.hpp ├── modules └── BS.thread_pool.cppm ├── pyproject.toml ├── scripts ├── clear_folder.py ├── compile_cpp.py └── test_all.py └── tests └── BS_thread_pool_test.cpp /.clang-format: -------------------------------------------------------------------------------- 1 | AccessModifierOffset: -4 2 | AlignAfterOpenBracket: DontAlign 3 | AlignArrayOfStructures: None 4 | AlignConsecutiveAssignments: None 5 | AlignConsecutiveBitFields: None 6 | AlignConsecutiveDeclarations: None 7 | AlignConsecutiveMacros: None 8 | AlignConsecutiveShortCaseStatements: 9 | Enabled: false 10 | AlignEscapedNewlines: Left 11 | AlignOperands: DontAlign 12 | AlignTrailingComments: 13 | Kind: Always 14 | OverEmptyLines: 0 15 | AllowAllArgumentsOnNextLine: false 16 | AllowAllParametersOfDeclarationOnNextLine: false 17 | AllowBreakBeforeNoexceptSpecifier: Never 18 | AllowShortBlocksOnASingleLine: Empty 19 | AllowShortCaseLabelsOnASingleLine: false 20 | AllowShortCompoundRequirementOnASingleLine: true 21 | AllowShortEnumsOnASingleLine: false 22 | AllowShortFunctionsOnASingleLine: Empty 23 | AllowShortIfStatementsOnASingleLine: Never 24 | AllowShortLambdasOnASingleLine: Empty 25 | AllowShortLoopsOnASingleLine: false 26 | AlwaysBreakAfterReturnType: None 27 | AlwaysBreakBeforeMultilineStrings: false 28 | AlwaysBreakTemplateDeclarations: Yes 29 | AttributeMacros: [] 30 | BinPackArguments: true 31 | BinPackParameters: true 32 | BitFieldColonSpacing: Both 33 | BraceWrapping: 34 | AfterCaseLabel: true 35 | AfterClass: true 36 | AfterControlStatement: Always 37 | AfterEnum: true 38 | AfterExternBlock: true 39 | AfterFunction: true 40 | AfterNamespace: false 41 | AfterStruct: true 42 | AfterUnion: true 43 | BeforeCatch: true 44 | BeforeElse: true 45 | BeforeLambdaBody: true 46 | BeforeWhile: false 47 | IndentBraces: false 48 | SplitEmptyFunction: true 49 | SplitEmptyNamespace: true 50 | SplitEmptyRecord: true 51 | BracedInitializerIndentWidth: 4 52 | BreakAdjacentStringLiterals: false 53 | BreakAfterAttributes: Never 54 | BreakBeforeBinaryOperators: None 55 | BreakBeforeBraces: Custom 56 | BreakBeforeConceptDeclarations: true 57 | BreakBeforeInheritanceComma: false 58 | BreakBeforeTernaryOperators: true 59 | BreakConstructorInitializers: BeforeColon 60 | BreakConstructorInitializersBeforeComma: false 61 | BreakInheritanceList: BeforeColon 62 | BreakStringLiterals: true 63 | ColumnLimit: 1024 64 | CompactNamespaces: false 65 | ConstructorInitializerAllOnOneLineOrOnePerLine: false 66 | ConstructorInitializerIndentWidth: 4 67 | ContinuationIndentWidth: 4 68 | Cpp11BracedListStyle: true 69 | DeriveLineEnding: true 70 | DerivePointerAlignment: false 71 | DisableFormat: false 72 | EmptyLineAfterAccessModifier: Never 73 | EmptyLineBeforeAccessModifier: LogicalBlock 74 | ExperimentalAutoDetectBinPacking: false 75 | FixNamespaceComments: true 76 | IncludeBlocks: Preserve 77 | IncludeIsMainSourceRegex: '' 78 | IndentAccessModifiers: false 79 | IndentCaseBlocks: false 80 | IndentCaseLabels: false 81 | IndentExternBlock: AfterExternBlock 82 | IndentGotoLabels: true 83 | IndentPPDirectives: BeforeHash 84 | IndentRequires: false 85 | IndentWidth: 4 86 | IndentWrappedFunctionNames: false 87 | JavaScriptQuotes: Leave 88 | JavaScriptWrapImports: true 89 | KeepEmptyLinesAtTheStartOfBlocks: true 90 | LambdaBodyIndentation: Signature 91 | Language: Cpp 92 | MacroBlockBegin: '' 93 | MacroBlockEnd: '' 94 | MaxEmptyLinesToKeep: 1 95 | NamespaceIndentation: Inner 96 | ObjCBinPackProtocolList: Auto 97 | ObjCBlockIndentWidth: 4 98 | ObjCBreakBeforeNestedBlockParam: true 99 | ObjCSpaceAfterProperty: false 100 | ObjCSpaceBeforeProtocolList: true 101 | PPIndentWidth: -1 102 | PackConstructorInitializers: BinPack 103 | PenaltyBreakAssignment: 0 104 | PenaltyBreakBeforeFirstCallParameter: 0 105 | PenaltyBreakComment: 0 106 | PenaltyBreakFirstLessLess: 0 107 | PenaltyBreakOpenParenthesis: 0 108 | PenaltyBreakString: 0 109 | PenaltyBreakTemplateDeclaration: 0 110 | PenaltyExcessCharacter: 0 111 | PenaltyIndentedWhitespace: 0 112 | PenaltyReturnTypeOnItsOwnLine: 0 113 | PointerAlignment: Left 114 | QualifierAlignment: Leave 115 | ReferenceAlignment: Pointer 116 | ReflowComments: true 117 | RemoveBracesLLVM: false 118 | SeparateDefinitionBlocks: Always 119 | ShortNamespaceLines: 1 120 | SkipMacroDefinitionBody: true 121 | SortIncludes: CaseSensitive 122 | SortJavaStaticImport: Before 123 | SortUsingDeclarations: true 124 | SpaceAfterCStyleCast: false 125 | SpaceAfterLogicalNot: false 126 | SpaceAfterTemplateKeyword: true 127 | SpaceAroundPointerQualifiers: Default 128 | SpaceBeforeAssignmentOperators: true 129 | SpaceBeforeCaseColon: false 130 | SpaceBeforeCpp11BracedList: false 131 | SpaceBeforeCtorInitializerColon: true 132 | SpaceBeforeInheritanceColon: true 133 | SpaceBeforeParens: ControlStatements 134 | SpaceBeforeParensOptions: 135 | AfterControlStatements: true 136 | AfterForeachMacros: true 137 | AfterFunctionDeclarationName: false 138 | AfterFunctionDefinitionName: false 139 | AfterIfMacros: true 140 | AfterOverloadedOperator: false 141 | BeforeNonEmptyParentheses: false 142 | SpaceBeforeRangeBasedForLoopColon: true 143 | SpaceBeforeSquareBrackets: false 144 | SpaceInEmptyBlock: false 145 | SpaceInEmptyParentheses: false 146 | SpacesBeforeTrailingComments: 1 147 | SpacesInAngles: Never 148 | SpacesInCStyleCastParentheses: false 149 | SpacesInConditionalStatement: false 150 | SpacesInContainerLiterals: true 151 | SpacesInLineCommentPrefix: 152 | Maximum: 1 153 | Minimum: 1 154 | SpacesInParentheses: false 155 | SpacesInSquareBrackets: false 156 | Standard: Latest 157 | TabWidth: 4 158 | UseCRLF: false 159 | UseTab: Never 160 | -------------------------------------------------------------------------------- /.clang-tidy: -------------------------------------------------------------------------------- 1 | CheckOptions: 2 | misc-const-correctness.WarnPointersAsValues: true 3 | misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic: true 4 | readability-magic-numbers.IgnoredIntegerValues: 0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10 5 | Checks: > 6 | *, 7 | -abseil-*, 8 | -altera-*, 9 | -android-*, 10 | -boost-*, 11 | -bugprone-easily-swappable-parameters, 12 | -bugprone-empty-catch, 13 | -cert-err58-cpp, 14 | -cppcoreguidelines-avoid-c-arrays, 15 | -cppcoreguidelines-avoid-do-while, 16 | -cppcoreguidelines-avoid-magic-numbers, 17 | -cppcoreguidelines-avoid-non-const-global-variables, 18 | -cppcoreguidelines-macro-usage, 19 | -cppcoreguidelines-pro-bounds-array-to-pointer-decay, 20 | -cppcoreguidelines-pro-bounds-constant-array-index, 21 | -cppcoreguidelines-pro-bounds-pointer-arithmetic, 22 | -cppcoreguidelines-pro-type-reinterpret-cast, 23 | -cppcoreguidelines-pro-type-vararg, 24 | -darwin-*, 25 | -fuchsia-*, 26 | -google-*, 27 | -hicpp-avoid-c-arrays, 28 | -hicpp-braces-around-statements, 29 | -hicpp-no-array-decay, 30 | -hicpp-signed-bitwise, 31 | -hicpp-use-auto, 32 | -hicpp-vararg, 33 | -linuxkernel-*, 34 | -llvm-*, 35 | -llvmlibc-*, 36 | -misc-definitions-in-headers, 37 | -misc-use-internal-linkage, 38 | -modernize-avoid-bind, 39 | -modernize-avoid-c-arrays, 40 | -modernize-use-auto, 41 | -modernize-use-constraints, 42 | -modernize-use-designated-initializers, 43 | -modernize-use-ranges, 44 | -modernize-use-std-numbers, 45 | -modernize-use-trailing-return-type, 46 | -mpi-*, 47 | -objc-*, 48 | -openmp-*, 49 | -performance-enum-size, 50 | -readability-avoid-nested-conditional-operator, 51 | -readability-braces-around-statements, 52 | -readability-function-cognitive-complexity, 53 | -readability-identifier-length, 54 | -zircon-*, 55 | HeaderFileExtensions: [h, hpp, cppm] 56 | HeaderFilterRegex: .* 57 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Found a bug? Report it here. 4 | title: "[BUG]" 5 | labels: bug 6 | --- 7 | 8 | **Describe the bug** 9 | 10 | A clear and concise description of what the bug is. 11 | 12 | **Minimal working example** 13 | 14 | A short but complete program that can be compiled to reproduce the error. Paste the program between the two code fences. If it's too long or requires multiple files, attach the file(s) instead. 15 | 16 | ```cpp 17 | ``` 18 | 19 | **Behavior** 20 | 21 | What behavior did you expect to get? What actually happened? If the code failed to compile, please include the full output of the compiler. 22 | 23 | **System information** 24 | 25 | * CPU model, architecture, # of cores and threads: 26 | * Operating system: 27 | * Name and version of C++ compiler: 28 | * Full command used for compiling, including all compiler flags: 29 | * Thread pool library version: 30 | 31 | (Please note that only the latest version of the thread pool library is supported.) 32 | 33 | **Additional information** 34 | 35 | Include any additional information here. 36 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/failed-tests.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Failed tests 3 | about: The provided automated tests failed on your system? Report it here. 4 | title: "[TEST]" 5 | labels: bug 6 | --- 7 | 8 | **System information** 9 | 10 | * CPU model, architecture, # of cores and threads: 11 | * Operating system: 12 | * Name and version of C++ compiler: 13 | * Full command used for compiling, including all compiler flags: 14 | * Thread pool library version: 15 | 16 | (Please note that only the latest version of the thread pool library is supported.) 17 | 18 | **Log file** 19 | 20 | Please attach the log file generated by the automated test program to this issue. 21 | 22 | **Additional information** 23 | 24 | Include any additional information here. 25 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Want a new feature? Suggest it here. 4 | title: "[REQ]" 5 | labels: enhancement 6 | --- 7 | 8 | **Describe the new feature** 9 | 10 | A clear and concise description of the feature you want. 11 | 12 | **Code example** 13 | 14 | An example of code that utilizes the suggested feature. Paste or write it between the two code fences. 15 | 16 | ```cpp 17 | ``` 18 | 19 | **Additional information** 20 | 21 | Include any additional information here. 22 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | **Pull request policy (please read)** 2 | 3 | > Contributions are always welcome. However, I release my projects in cumulative updates after editing and testing them locally on my system, so **my policy is to never accept any pull requests**. If you open a pull request, and I decide to incorporate your suggestion into the project, I will first modify your code to comply with the project's coding conventions (formatting, syntax, naming, comments, programming practices, etc.), and perform some tests to ensure that the change doesn't break anything. I will then merge it into the next release of the project, possibly together with some other changes. The new release will also include a note in `CHANGELOG.md` with a link to your pull request, and modifications to the documentation in `README.md` as needed. 4 | 5 | **Describe the changes** 6 | 7 | What does your pull request fix or add to the library? 8 | 9 | **Style** 10 | 11 | Have you formatted your code using the `.clang-format` file attached to this project? 12 | 13 | **Linting** 14 | 15 | Have you linted your code using the `.clang-tidy` file attached to this project? 16 | 17 | **Testing** 18 | 19 | Have you tested the new code using the provided automated test program `BS_thread_pool_test.cpp` (preferably with the provided test script `test_all.py`) and/or performed any other tests to ensure that the new code works correctly? 20 | 21 | If so, please provide information about the test system(s): 22 | 23 | * CPU model, architecture, # of cores and threads: 24 | * Operating system: 25 | * Name and version of C++ compiler: 26 | * Full command used for compiling, including all compiler flags: 27 | 28 | **Additional information** 29 | 30 | Include any additional information here. 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | temp 3 | -------------------------------------------------------------------------------- /.vscode-linux/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "browse": { 5 | "limitSymbolsToIncludedHeaders": true 6 | }, 7 | "compilerArgs": [ 8 | "-stdlib=libc++" 9 | ], 10 | "compilerPath": "/usr/bin/clang++", 11 | "cppStandard": "c++17", 12 | "cStandard": "c17", 13 | "defines": [ 14 | "BS_THREAD_POOL_NATIVE_EXTENSIONS" 15 | ], 16 | "includePath": [ 17 | "${workspaceFolder}/**" 18 | ], 19 | "intelliSenseMode": "linux-clang-x64", 20 | "name": "Clang C++17" 21 | }, 22 | { 23 | "browse": { 24 | "limitSymbolsToIncludedHeaders": true 25 | }, 26 | "compilerArgs": [ 27 | "-stdlib=libc++" 28 | ], 29 | "compilerPath": "/usr/bin/clang++", 30 | "cppStandard": "c++20", 31 | "cStandard": "c17", 32 | "defines": [ 33 | "BS_THREAD_POOL_NATIVE_EXTENSIONS" 34 | ], 35 | "includePath": [ 36 | "${workspaceFolder}/**" 37 | ], 38 | "intelliSenseMode": "linux-clang-x64", 39 | "name": "Clang C++20" 40 | }, 41 | { 42 | "browse": { 43 | "limitSymbolsToIncludedHeaders": true 44 | }, 45 | "compilerArgs": [ 46 | "-stdlib=libc++" 47 | ], 48 | "compilerPath": "/usr/bin/clang++", 49 | "cppStandard": "c++23", 50 | "cStandard": "c23", 51 | "defines": [ 52 | "BS_THREAD_POOL_NATIVE_EXTENSIONS" 53 | ], 54 | "includePath": [ 55 | "${workspaceFolder}/**" 56 | ], 57 | "intelliSenseMode": "linux-clang-x64", 58 | "name": "Clang C++23" 59 | }, 60 | { 61 | "browse": { 62 | "limitSymbolsToIncludedHeaders": true 63 | }, 64 | "compilerPath": "/usr/bin/g++", 65 | "cppStandard": "c++17", 66 | "cStandard": "c17", 67 | "defines": [ 68 | "BS_THREAD_POOL_NATIVE_EXTENSIONS" 69 | ], 70 | "includePath": [ 71 | "${workspaceFolder}/**" 72 | ], 73 | "intelliSenseMode": "linux-gcc-x64", 74 | "name": "GCC C++17" 75 | }, 76 | { 77 | "browse": { 78 | "limitSymbolsToIncludedHeaders": true 79 | }, 80 | "compilerPath": "/usr/bin/g++", 81 | "cppStandard": "c++20", 82 | "cStandard": "c17", 83 | "defines": [ 84 | "BS_THREAD_POOL_NATIVE_EXTENSIONS" 85 | ], 86 | "includePath": [ 87 | "${workspaceFolder}/**" 88 | ], 89 | "intelliSenseMode": "linux-gcc-x64", 90 | "name": "GCC C++20" 91 | }, 92 | { 93 | "browse": { 94 | "limitSymbolsToIncludedHeaders": true 95 | }, 96 | "compilerPath": "/usr/bin/g++", 97 | "cppStandard": "c++23", 98 | "cStandard": "c23", 99 | "defines": [ 100 | "BS_THREAD_POOL_NATIVE_EXTENSIONS" 101 | ], 102 | "includePath": [ 103 | "${workspaceFolder}/**" 104 | ], 105 | "intelliSenseMode": "linux-gcc-x64", 106 | "name": "GCC C++23" 107 | } 108 | ], 109 | "version": 4 110 | } 111 | -------------------------------------------------------------------------------- /.vscode-linux/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "args": [], 5 | "cwd": "${workspaceFolder}${/}build", 6 | "name": "Build and debug (Clang C++17)", 7 | "preLaunchTask": "Build for debugging (Clang C++17)", 8 | "program": "${workspaceFolder}${/}build${/}${fileBasenameNoExtension}_debug-clang-cpp17", 9 | "request": "launch", 10 | "type": "lldb" 11 | }, 12 | { 13 | "args": [], 14 | "cwd": "${workspaceFolder}${/}build", 15 | "name": "Build and debug (Clang C++20)", 16 | "preLaunchTask": "Build for debugging (Clang C++20)", 17 | "program": "${workspaceFolder}${/}build${/}${fileBasenameNoExtension}_debug-clang-cpp20", 18 | "request": "launch", 19 | "type": "lldb" 20 | }, 21 | { 22 | "args": [], 23 | "cwd": "${workspaceFolder}${/}build", 24 | "name": "Build and debug (Clang C++23)", 25 | "preLaunchTask": "Build for debugging (Clang C++23)", 26 | "program": "${workspaceFolder}${/}build${/}${fileBasenameNoExtension}_debug-clang-cpp23", 27 | "request": "launch", 28 | "type": "lldb" 29 | }, 30 | { 31 | "args": [], 32 | "cwd": "${workspaceFolder}${/}build", 33 | "name": "Build and debug (GCC C++17)", 34 | "preLaunchTask": "Build for debugging (GCC C++17)", 35 | "program": "${workspaceFolder}${/}build${/}${fileBasenameNoExtension}_debug-gcc-cpp17", 36 | "request": "launch", 37 | "type": "cppdbg" 38 | }, 39 | { 40 | "args": [], 41 | "cwd": "${workspaceFolder}${/}build", 42 | "name": "Build and debug (GCC C++20)", 43 | "preLaunchTask": "Build for debugging (GCC C++20)", 44 | "program": "${workspaceFolder}${/}build${/}${fileBasenameNoExtension}_debug-gcc-cpp20", 45 | "request": "launch", 46 | "type": "cppdbg" 47 | }, 48 | { 49 | "args": [], 50 | "cwd": "${workspaceFolder}${/}build", 51 | "name": "Build and debug (GCC C++23)", 52 | "preLaunchTask": "Build for debugging (GCC C++23)", 53 | "program": "${workspaceFolder}${/}build${/}${fileBasenameNoExtension}_debug-gcc-cpp23", 54 | "request": "launch", 55 | "type": "cppdbg" 56 | } 57 | ], 58 | "version": "0.2.0" 59 | } 60 | -------------------------------------------------------------------------------- /.vscode-linux/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "tasks": [ 3 | { 4 | "args": [ 5 | "scripts/compile_cpp.py", 6 | "${file}", 7 | "-c=clang++", 8 | "-s=c++17", 9 | "-t=debug", 10 | "-v" 11 | ], 12 | "command": "python3", 13 | "detail": "Compile active file using clang++ with warning and debugging flags.", 14 | "group": "build", 15 | "label": "Build for debugging (Clang C++17)", 16 | "presentation": { 17 | "clear": false, 18 | "echo": true, 19 | "focus": false, 20 | "panel": "shared", 21 | "reveal": "always", 22 | "revealProblems": "onProblem", 23 | "showReuseMessage": true 24 | }, 25 | "problemMatcher": [ 26 | "$gcc" 27 | ], 28 | "type": "cppbuild" 29 | }, 30 | { 31 | "args": [ 32 | "scripts/compile_cpp.py", 33 | "${file}", 34 | "-c=clang++", 35 | "-s=c++20", 36 | "-t=debug", 37 | "-v" 38 | ], 39 | "command": "python3", 40 | "detail": "Compile active file using clang++ with warning and debugging flags.", 41 | "group": "build", 42 | "label": "Build for debugging (Clang C++20)", 43 | "presentation": { 44 | "clear": false, 45 | "echo": true, 46 | "focus": false, 47 | "panel": "shared", 48 | "reveal": "always", 49 | "revealProblems": "onProblem", 50 | "showReuseMessage": true 51 | }, 52 | "problemMatcher": [ 53 | "$gcc" 54 | ], 55 | "type": "cppbuild" 56 | }, 57 | { 58 | "args": [ 59 | "scripts/compile_cpp.py", 60 | "${file}", 61 | "-c=clang++", 62 | "-s=c++23", 63 | "-t=debug", 64 | "-v" 65 | ], 66 | "command": "python3", 67 | "detail": "Compile active file using clang++ with warning and debugging flags.", 68 | "group": "build", 69 | "label": "Build for debugging (Clang C++23)", 70 | "presentation": { 71 | "clear": false, 72 | "echo": true, 73 | "focus": false, 74 | "panel": "shared", 75 | "reveal": "always", 76 | "revealProblems": "onProblem", 77 | "showReuseMessage": true 78 | }, 79 | "problemMatcher": [ 80 | "$gcc" 81 | ], 82 | "type": "cppbuild" 83 | }, 84 | { 85 | "args": [ 86 | "scripts/compile_cpp.py", 87 | "${file}", 88 | "-c=g++", 89 | "-s=c++17", 90 | "-t=debug", 91 | "-v" 92 | ], 93 | "command": "python3", 94 | "detail": "Compile active file using g++ with warning and debugging flags.", 95 | "group": "build", 96 | "label": "Build for debugging (GCC C++17)", 97 | "presentation": { 98 | "clear": false, 99 | "echo": true, 100 | "focus": false, 101 | "panel": "shared", 102 | "reveal": "always", 103 | "revealProblems": "onProblem", 104 | "showReuseMessage": true 105 | }, 106 | "problemMatcher": [ 107 | "$gcc" 108 | ], 109 | "type": "cppbuild" 110 | }, 111 | { 112 | "args": [ 113 | "scripts/compile_cpp.py", 114 | "${file}", 115 | "-c=g++", 116 | "-s=c++20", 117 | "-t=debug", 118 | "-v" 119 | ], 120 | "command": "python3", 121 | "detail": "Compile active file using g++ with warning and debugging flags.", 122 | "group": "build", 123 | "label": "Build for debugging (GCC C++20)", 124 | "presentation": { 125 | "clear": false, 126 | "echo": true, 127 | "focus": false, 128 | "panel": "shared", 129 | "reveal": "always", 130 | "revealProblems": "onProblem", 131 | "showReuseMessage": true 132 | }, 133 | "problemMatcher": [ 134 | "$gcc" 135 | ], 136 | "type": "cppbuild" 137 | }, 138 | { 139 | "args": [ 140 | "scripts/compile_cpp.py", 141 | "${file}", 142 | "-c=g++", 143 | "-s=c++23", 144 | "-t=debug", 145 | "-v" 146 | ], 147 | "command": "python3", 148 | "detail": "Compile active file using g++ with warning and debugging flags.", 149 | "group": "build", 150 | "label": "Build for debugging (GCC C++23)", 151 | "presentation": { 152 | "clear": false, 153 | "echo": true, 154 | "focus": false, 155 | "panel": "shared", 156 | "reveal": "always", 157 | "revealProblems": "onProblem", 158 | "showReuseMessage": true 159 | }, 160 | "problemMatcher": [ 161 | "$gcc" 162 | ], 163 | "type": "cppbuild" 164 | }, 165 | { 166 | "args": [ 167 | "scripts/compile_cpp.py", 168 | "${file}", 169 | "-c=clang++", 170 | "-s=c++17", 171 | "-t=release", 172 | "-v" 173 | ], 174 | "command": "python3", 175 | "detail": "Compile active file using clang++ with warning and optimization flags.", 176 | "group": "build", 177 | "label": "Build optimized (Clang C++17)", 178 | "presentation": { 179 | "clear": false, 180 | "echo": true, 181 | "focus": false, 182 | "panel": "shared", 183 | "reveal": "always", 184 | "revealProblems": "onProblem", 185 | "showReuseMessage": true 186 | }, 187 | "problemMatcher": [ 188 | "$gcc" 189 | ], 190 | "type": "cppbuild" 191 | }, 192 | { 193 | "args": [ 194 | "scripts/compile_cpp.py", 195 | "${file}", 196 | "-c=clang++", 197 | "-s=c++20", 198 | "-t=release", 199 | "-v" 200 | ], 201 | "command": "python3", 202 | "detail": "Compile active file using clang++ with warning and optimization flags.", 203 | "group": "build", 204 | "label": "Build optimized (Clang C++20)", 205 | "presentation": { 206 | "clear": false, 207 | "echo": true, 208 | "focus": false, 209 | "panel": "shared", 210 | "reveal": "always", 211 | "revealProblems": "onProblem", 212 | "showReuseMessage": true 213 | }, 214 | "problemMatcher": [ 215 | "$gcc" 216 | ], 217 | "type": "cppbuild" 218 | }, 219 | { 220 | "args": [ 221 | "scripts/compile_cpp.py", 222 | "${file}", 223 | "-c=clang++", 224 | "-s=c++23", 225 | "-t=release", 226 | "-v" 227 | ], 228 | "command": "python3", 229 | "detail": "Compile active file using clang++ with warning and optimization flags.", 230 | "group": "build", 231 | "label": "Build optimized (Clang C++23)", 232 | "presentation": { 233 | "clear": false, 234 | "echo": true, 235 | "focus": false, 236 | "panel": "shared", 237 | "reveal": "always", 238 | "revealProblems": "onProblem", 239 | "showReuseMessage": true 240 | }, 241 | "problemMatcher": [ 242 | "$gcc" 243 | ], 244 | "type": "cppbuild" 245 | }, 246 | { 247 | "args": [ 248 | "scripts/compile_cpp.py", 249 | "${file}", 250 | "-c=g++", 251 | "-s=c++17", 252 | "-t=release", 253 | "-v" 254 | ], 255 | "command": "python3", 256 | "detail": "Compile active file using g++ with warning and optimization flags.", 257 | "group": "build", 258 | "label": "Build optimized (GCC C++17)", 259 | "presentation": { 260 | "clear": false, 261 | "echo": true, 262 | "focus": false, 263 | "panel": "shared", 264 | "reveal": "always", 265 | "revealProblems": "onProblem", 266 | "showReuseMessage": true 267 | }, 268 | "problemMatcher": [ 269 | "$gcc" 270 | ], 271 | "type": "cppbuild" 272 | }, 273 | { 274 | "args": [ 275 | "scripts/compile_cpp.py", 276 | "${file}", 277 | "-c=g++", 278 | "-s=c++20", 279 | "-t=release", 280 | "-v" 281 | ], 282 | "command": "python3", 283 | "detail": "Compile active file using g++ with warning and optimization flags.", 284 | "group": "build", 285 | "label": "Build optimized (GCC C++20)", 286 | "presentation": { 287 | "clear": false, 288 | "echo": true, 289 | "focus": false, 290 | "panel": "shared", 291 | "reveal": "always", 292 | "revealProblems": "onProblem", 293 | "showReuseMessage": true 294 | }, 295 | "problemMatcher": [ 296 | "$gcc" 297 | ], 298 | "type": "cppbuild" 299 | }, 300 | { 301 | "args": [ 302 | "scripts/compile_cpp.py", 303 | "${file}", 304 | "-c=g++", 305 | "-s=c++23", 306 | "-t=release", 307 | "-v" 308 | ], 309 | "command": "python3", 310 | "detail": "Compile active file using g++ with warning and optimization flags.", 311 | "group": "build", 312 | "label": "Build optimized (GCC C++23)", 313 | "presentation": { 314 | "clear": false, 315 | "echo": true, 316 | "focus": false, 317 | "panel": "shared", 318 | "reveal": "always", 319 | "revealProblems": "onProblem", 320 | "showReuseMessage": true 321 | }, 322 | "problemMatcher": [ 323 | "$gcc" 324 | ], 325 | "type": "cppbuild" 326 | }, 327 | { 328 | "args": [ 329 | "scripts/compile_cpp.py", 330 | "${file}", 331 | "-c=clang++", 332 | "-s=c++17", 333 | "-t=release", 334 | "-r", 335 | "-v" 336 | ], 337 | "command": "python3", 338 | "detail": "Compile active file using clang++ with warning and optimization flags and run the program.", 339 | "group": "test", 340 | "label": "Build optimized and run (Clang C++17)", 341 | "presentation": { 342 | "clear": false, 343 | "echo": true, 344 | "focus": false, 345 | "panel": "shared", 346 | "reveal": "always", 347 | "revealProblems": "onProblem", 348 | "showReuseMessage": true 349 | } 350 | }, 351 | { 352 | "args": [ 353 | "scripts/compile_cpp.py", 354 | "${file}", 355 | "-c=clang++", 356 | "-s=c++20", 357 | "-t=release", 358 | "-r", 359 | "-v" 360 | ], 361 | "command": "python3", 362 | "detail": "Compile active file using clang++ with warning and optimization flags and run the program.", 363 | "group": "test", 364 | "label": "Build optimized and run (Clang C++20)", 365 | "presentation": { 366 | "clear": false, 367 | "echo": true, 368 | "focus": false, 369 | "panel": "shared", 370 | "reveal": "always", 371 | "revealProblems": "onProblem", 372 | "showReuseMessage": true 373 | } 374 | }, 375 | { 376 | "args": [ 377 | "scripts/compile_cpp.py", 378 | "${file}", 379 | "-c=clang++", 380 | "-s=c++23", 381 | "-t=release", 382 | "-r", 383 | "-v" 384 | ], 385 | "command": "python3", 386 | "detail": "Compile active file using clang++ with warning and optimization flags and run the program.", 387 | "group": "test", 388 | "label": "Build optimized and run (Clang C++23)", 389 | "presentation": { 390 | "clear": false, 391 | "echo": true, 392 | "focus": false, 393 | "panel": "shared", 394 | "reveal": "always", 395 | "revealProblems": "onProblem", 396 | "showReuseMessage": true 397 | } 398 | }, 399 | { 400 | "args": [ 401 | "scripts/compile_cpp.py", 402 | "${file}", 403 | "-c=g++", 404 | "-s=c++17", 405 | "-t=release", 406 | "-r", 407 | "-v" 408 | ], 409 | "command": "python3", 410 | "detail": "Compile active file using g++ with warning and optimization flags and run the program.", 411 | "group": "test", 412 | "label": "Build optimized and run (GCC C++17)", 413 | "presentation": { 414 | "clear": false, 415 | "echo": true, 416 | "focus": false, 417 | "panel": "shared", 418 | "reveal": "always", 419 | "revealProblems": "onProblem", 420 | "showReuseMessage": true 421 | } 422 | }, 423 | { 424 | "args": [ 425 | "scripts/compile_cpp.py", 426 | "${file}", 427 | "-c=g++", 428 | "-s=c++20", 429 | "-t=release", 430 | "-r", 431 | "-v" 432 | ], 433 | "command": "python3", 434 | "detail": "Compile active file using g++ with warning and optimization flags and run the program.", 435 | "group": "test", 436 | "label": "Build optimized and run (GCC C++20)", 437 | "presentation": { 438 | "clear": false, 439 | "echo": true, 440 | "focus": false, 441 | "panel": "shared", 442 | "reveal": "always", 443 | "revealProblems": "onProblem", 444 | "showReuseMessage": true 445 | } 446 | }, 447 | { 448 | "args": [ 449 | "scripts/compile_cpp.py", 450 | "${file}", 451 | "-c=g++", 452 | "-s=c++23", 453 | "-t=release", 454 | "-r", 455 | "-v" 456 | ], 457 | "command": "python3", 458 | "detail": "Compile active file using g++ with warning and optimization flags and run the program.", 459 | "group": "test", 460 | "label": "Build optimized and run (GCC C++23)", 461 | "presentation": { 462 | "clear": false, 463 | "echo": true, 464 | "focus": false, 465 | "panel": "shared", 466 | "reveal": "always", 467 | "revealProblems": "onProblem", 468 | "showReuseMessage": true 469 | } 470 | }, 471 | { 472 | "args": [ 473 | "scripts/clear_folder.py", 474 | "../build" 475 | ], 476 | "command": "python3", 477 | "detail": "Delete all files in the build folder.", 478 | "group": "test", 479 | "label": "Clear build folder", 480 | "presentation": { 481 | "clear": false, 482 | "echo": true, 483 | "focus": false, 484 | "panel": "shared", 485 | "reveal": "always", 486 | "revealProblems": "onProblem", 487 | "showReuseMessage": true 488 | }, 489 | "type": "shell" 490 | }, 491 | { 492 | "args": [ 493 | "scripts/clear_folder.py", 494 | "../temp" 495 | ], 496 | "command": "python3", 497 | "detail": "Delete all files in the temp folder.", 498 | "group": "test", 499 | "label": "Clear temp folder", 500 | "presentation": { 501 | "clear": false, 502 | "echo": true, 503 | "focus": false, 504 | "panel": "shared", 505 | "reveal": "always", 506 | "revealProblems": "onProblem", 507 | "showReuseMessage": true 508 | }, 509 | "type": "shell" 510 | }, 511 | { 512 | "args": [ 513 | "scripts/test_all.py" 514 | ], 515 | "command": "python3", 516 | "detail": "Compile and run the test program with all available compilers and all relevant C++ standards.", 517 | "group": "test", 518 | "label": "Run all tests", 519 | "presentation": { 520 | "clear": false, 521 | "echo": true, 522 | "focus": false, 523 | "panel": "shared", 524 | "reveal": "always", 525 | "revealProblems": "onProblem", 526 | "showReuseMessage": true 527 | }, 528 | "type": "shell" 529 | } 530 | ], 531 | "version": "2.0.0" 532 | } 533 | -------------------------------------------------------------------------------- /.vscode-macos/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "compilerPath": "/usr/local/opt/llvm/bin/clang++", 5 | "cppStandard": "c++17", 6 | "cStandard": "c17", 7 | "defines": [ 8 | "BS_THREAD_POOL_NATIVE_EXTENSIONS" 9 | ], 10 | "includePath": [ 11 | "${workspaceFolder}/**" 12 | ], 13 | "intelliSenseMode": "macos-clang-x64", 14 | "name": "Clang C++17" 15 | }, 16 | { 17 | "compilerPath": "/usr/local/opt/llvm/bin/clang++", 18 | "cppStandard": "c++20", 19 | "cStandard": "c17", 20 | "defines": [ 21 | "BS_THREAD_POOL_NATIVE_EXTENSIONS" 22 | ], 23 | "includePath": [ 24 | "${workspaceFolder}/**" 25 | ], 26 | "intelliSenseMode": "macos-clang-x64", 27 | "name": "Clang C++20" 28 | }, 29 | { 30 | "compilerPath": "/usr/local/opt/llvm/bin/clang++", 31 | "cppStandard": "c++23", 32 | "cStandard": "c23", 33 | "defines": [ 34 | "BS_THREAD_POOL_NATIVE_EXTENSIONS" 35 | ], 36 | "includePath": [ 37 | "${workspaceFolder}/**" 38 | ], 39 | "intelliSenseMode": "macos-clang-x64", 40 | "name": "Clang C++23" 41 | } 42 | ], 43 | "version": 4 44 | } 45 | -------------------------------------------------------------------------------- /.vscode-macos/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "args": [], 5 | "cwd": "${workspaceFolder}${/}build", 6 | "name": "Build and debug (Clang C++17)", 7 | "preLaunchTask": "Build for debugging (Clang C++17)", 8 | "program": "${workspaceFolder}${/}build${/}${fileBasenameNoExtension}_debug-clang-cpp17", 9 | "request": "launch", 10 | "type": "lldb" 11 | }, 12 | { 13 | "args": [], 14 | "cwd": "${workspaceFolder}${/}build", 15 | "name": "Build and debug (Clang C++20)", 16 | "preLaunchTask": "Build for debugging (Clang C++20)", 17 | "program": "${workspaceFolder}${/}build${/}${fileBasenameNoExtension}_debug-clang-cpp20", 18 | "request": "launch", 19 | "type": "lldb" 20 | }, 21 | { 22 | "args": [], 23 | "cwd": "${workspaceFolder}${/}build", 24 | "name": "Build and debug (Clang C++23)", 25 | "preLaunchTask": "Build for debugging (Clang C++23)", 26 | "program": "${workspaceFolder}${/}build${/}${fileBasenameNoExtension}_debug-clang-cpp23", 27 | "request": "launch", 28 | "type": "lldb" 29 | } 30 | ], 31 | "version": "0.2.0" 32 | } 33 | -------------------------------------------------------------------------------- /.vscode-macos/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "tasks": [ 3 | { 4 | "args": [ 5 | "scripts/compile_cpp.py", 6 | "${file}", 7 | "-c=clang++", 8 | "-s=c++17", 9 | "-t=debug", 10 | "-v" 11 | ], 12 | "command": "python3", 13 | "detail": "Compile active file using clang++ with warning and debugging flags.", 14 | "group": "build", 15 | "label": "Build for debugging (Clang C++17)", 16 | "presentation": { 17 | "clear": false, 18 | "echo": true, 19 | "focus": false, 20 | "panel": "shared", 21 | "reveal": "always", 22 | "revealProblems": "onProblem", 23 | "showReuseMessage": true 24 | }, 25 | "problemMatcher": [ 26 | "$gcc" 27 | ], 28 | "type": "cppbuild" 29 | }, 30 | { 31 | "args": [ 32 | "scripts/compile_cpp.py", 33 | "${file}", 34 | "-c=clang++", 35 | "-s=c++20", 36 | "-t=debug", 37 | "-v" 38 | ], 39 | "command": "python3", 40 | "detail": "Compile active file using clang++ with warning and debugging flags.", 41 | "group": "build", 42 | "label": "Build for debugging (Clang C++20)", 43 | "presentation": { 44 | "clear": false, 45 | "echo": true, 46 | "focus": false, 47 | "panel": "shared", 48 | "reveal": "always", 49 | "revealProblems": "onProblem", 50 | "showReuseMessage": true 51 | }, 52 | "problemMatcher": [ 53 | "$gcc" 54 | ], 55 | "type": "cppbuild" 56 | }, 57 | { 58 | "args": [ 59 | "scripts/compile_cpp.py", 60 | "${file}", 61 | "-c=clang++", 62 | "-s=c++23", 63 | "-t=debug", 64 | "-v" 65 | ], 66 | "command": "python3", 67 | "detail": "Compile active file using clang++ with warning and debugging flags.", 68 | "group": "build", 69 | "label": "Build for debugging (Clang C++23)", 70 | "presentation": { 71 | "clear": false, 72 | "echo": true, 73 | "focus": false, 74 | "panel": "shared", 75 | "reveal": "always", 76 | "revealProblems": "onProblem", 77 | "showReuseMessage": true 78 | }, 79 | "problemMatcher": [ 80 | "$gcc" 81 | ], 82 | "type": "cppbuild" 83 | }, 84 | { 85 | "args": [ 86 | "scripts/compile_cpp.py", 87 | "${file}", 88 | "-c=clang++", 89 | "-s=c++17", 90 | "-t=release", 91 | "-v" 92 | ], 93 | "command": "python3", 94 | "detail": "Compile active file using clang++ with warning and optimization flags.", 95 | "group": "build", 96 | "label": "Build optimized (Clang C++17)", 97 | "presentation": { 98 | "clear": false, 99 | "echo": true, 100 | "focus": false, 101 | "panel": "shared", 102 | "reveal": "always", 103 | "revealProblems": "onProblem", 104 | "showReuseMessage": true 105 | }, 106 | "problemMatcher": [ 107 | "$gcc" 108 | ], 109 | "type": "cppbuild" 110 | }, 111 | { 112 | "args": [ 113 | "scripts/compile_cpp.py", 114 | "${file}", 115 | "-c=clang++", 116 | "-s=c++20", 117 | "-t=release", 118 | "-v" 119 | ], 120 | "command": "python3", 121 | "detail": "Compile active file using clang++ with warning and optimization flags.", 122 | "group": "build", 123 | "label": "Build optimized (Clang C++20)", 124 | "presentation": { 125 | "clear": false, 126 | "echo": true, 127 | "focus": false, 128 | "panel": "shared", 129 | "reveal": "always", 130 | "revealProblems": "onProblem", 131 | "showReuseMessage": true 132 | }, 133 | "problemMatcher": [ 134 | "$gcc" 135 | ], 136 | "type": "cppbuild" 137 | }, 138 | { 139 | "args": [ 140 | "scripts/compile_cpp.py", 141 | "${file}", 142 | "-c=clang++", 143 | "-s=c++23", 144 | "-t=release", 145 | "-v" 146 | ], 147 | "command": "python3", 148 | "detail": "Compile active file using clang++ with warning and optimization flags.", 149 | "group": "build", 150 | "label": "Build optimized (Clang C++23)", 151 | "presentation": { 152 | "clear": false, 153 | "echo": true, 154 | "focus": false, 155 | "panel": "shared", 156 | "reveal": "always", 157 | "revealProblems": "onProblem", 158 | "showReuseMessage": true 159 | }, 160 | "problemMatcher": [ 161 | "$gcc" 162 | ], 163 | "type": "cppbuild" 164 | }, 165 | { 166 | "args": [ 167 | "scripts/compile_cpp.py", 168 | "${file}", 169 | "-c=clang++", 170 | "-s=c++17", 171 | "-t=release", 172 | "-r", 173 | "-v" 174 | ], 175 | "command": "python3", 176 | "detail": "Compile active file using clang++ with warning and optimization flags and run the program.", 177 | "group": "test", 178 | "label": "Build optimized and run (Clang C++17)", 179 | "presentation": { 180 | "clear": false, 181 | "echo": true, 182 | "focus": false, 183 | "panel": "shared", 184 | "reveal": "always", 185 | "revealProblems": "onProblem", 186 | "showReuseMessage": true 187 | } 188 | }, 189 | { 190 | "args": [ 191 | "scripts/compile_cpp.py", 192 | "${file}", 193 | "-c=clang++", 194 | "-s=c++20", 195 | "-t=release", 196 | "-r", 197 | "-v" 198 | ], 199 | "command": "python3", 200 | "detail": "Compile active file using clang++ with warning and optimization flags and run the program.", 201 | "group": "test", 202 | "label": "Build optimized and run (Clang C++20)", 203 | "presentation": { 204 | "clear": false, 205 | "echo": true, 206 | "focus": false, 207 | "panel": "shared", 208 | "reveal": "always", 209 | "revealProblems": "onProblem", 210 | "showReuseMessage": true 211 | } 212 | }, 213 | { 214 | "args": [ 215 | "scripts/compile_cpp.py", 216 | "${file}", 217 | "-c=clang++", 218 | "-s=c++23", 219 | "-t=release", 220 | "-r", 221 | "-v" 222 | ], 223 | "command": "python3", 224 | "detail": "Compile active file using clang++ with warning and optimization flags and run the program.", 225 | "group": "test", 226 | "label": "Build optimized and run (Clang C++23)", 227 | "presentation": { 228 | "clear": false, 229 | "echo": true, 230 | "focus": false, 231 | "panel": "shared", 232 | "reveal": "always", 233 | "revealProblems": "onProblem", 234 | "showReuseMessage": true 235 | } 236 | }, 237 | { 238 | "args": [ 239 | "scripts/clear_folder.py", 240 | "../build" 241 | ], 242 | "command": "python3", 243 | "detail": "Delete all files in the build folder.", 244 | "group": "test", 245 | "label": "Clear build folder", 246 | "presentation": { 247 | "clear": false, 248 | "echo": true, 249 | "focus": false, 250 | "panel": "shared", 251 | "reveal": "always", 252 | "revealProblems": "onProblem", 253 | "showReuseMessage": true 254 | }, 255 | "type": "shell" 256 | }, 257 | { 258 | "args": [ 259 | "scripts/clear_folder.py", 260 | "../temp" 261 | ], 262 | "command": "python3", 263 | "detail": "Delete all files in the temp folder.", 264 | "group": "test", 265 | "label": "Clear temp folder", 266 | "presentation": { 267 | "clear": false, 268 | "echo": true, 269 | "focus": false, 270 | "panel": "shared", 271 | "reveal": "always", 272 | "revealProblems": "onProblem", 273 | "showReuseMessage": true 274 | }, 275 | "type": "shell" 276 | }, 277 | { 278 | "args": [ 279 | "scripts/test_all.py" 280 | ], 281 | "command": "python3", 282 | "detail": "Compile and run the test program with all available compilers and all relevant C++ standards.", 283 | "group": "test", 284 | "label": "Run all tests", 285 | "presentation": { 286 | "clear": false, 287 | "echo": true, 288 | "focus": false, 289 | "panel": "shared", 290 | "reveal": "always", 291 | "revealProblems": "onProblem", 292 | "showReuseMessage": true 293 | }, 294 | "type": "shell" 295 | } 296 | ], 297 | "version": "2.0.0" 298 | } 299 | -------------------------------------------------------------------------------- /.vscode-windows/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "browse": { 5 | "limitSymbolsToIncludedHeaders": true 6 | }, 7 | "compilerArgs": [ 8 | "-stdlib=libc++" 9 | ], 10 | "compilerPath": "C:/msys64/clang64/bin/clang++.exe", 11 | "cppStandard": "c++17", 12 | "cStandard": "c17", 13 | "defines": [ 14 | "BS_THREAD_POOL_NATIVE_EXTENSIONS" 15 | ], 16 | "includePath": [ 17 | "${workspaceFolder}/**" 18 | ], 19 | "intelliSenseMode": "windows-clang-x64", 20 | "name": "Clang C++17" 21 | }, 22 | { 23 | "browse": { 24 | "limitSymbolsToIncludedHeaders": true 25 | }, 26 | "compilerArgs": [ 27 | "-stdlib=libc++" 28 | ], 29 | "compilerPath": "C:/msys64/clang64/bin/clang++.exe", 30 | "cppStandard": "c++20", 31 | "cStandard": "c17", 32 | "defines": [ 33 | "BS_THREAD_POOL_NATIVE_EXTENSIONS" 34 | ], 35 | "includePath": [ 36 | "${workspaceFolder}/**" 37 | ], 38 | "intelliSenseMode": "windows-clang-x64", 39 | "name": "Clang C++20" 40 | }, 41 | { 42 | "browse": { 43 | "limitSymbolsToIncludedHeaders": true 44 | }, 45 | "compilerArgs": [ 46 | "-stdlib=libc++" 47 | ], 48 | "compilerPath": "C:/msys64/clang64/bin/clang++.exe", 49 | "cppStandard": "c++23", 50 | "cStandard": "c23", 51 | "defines": [ 52 | "BS_THREAD_POOL_NATIVE_EXTENSIONS" 53 | ], 54 | "includePath": [ 55 | "${workspaceFolder}/**" 56 | ], 57 | "intelliSenseMode": "windows-clang-x64", 58 | "name": "Clang C++23" 59 | }, 60 | { 61 | "browse": { 62 | "limitSymbolsToIncludedHeaders": true 63 | }, 64 | "compilerPath": "C:/msys64/ucrt64/bin/g++.exe", 65 | "cppStandard": "c++17", 66 | "cStandard": "c17", 67 | "defines": [ 68 | "BS_THREAD_POOL_NATIVE_EXTENSIONS" 69 | ], 70 | "includePath": [ 71 | "${workspaceFolder}/**" 72 | ], 73 | "intelliSenseMode": "windows-gcc-x64", 74 | "name": "GCC C++17" 75 | }, 76 | { 77 | "browse": { 78 | "limitSymbolsToIncludedHeaders": true 79 | }, 80 | "compilerPath": "C:/msys64/ucrt64/bin/g++.exe", 81 | "cppStandard": "c++20", 82 | "cStandard": "c17", 83 | "defines": [ 84 | "BS_THREAD_POOL_NATIVE_EXTENSIONS" 85 | ], 86 | "includePath": [ 87 | "${workspaceFolder}/**" 88 | ], 89 | "intelliSenseMode": "windows-gcc-x64", 90 | "name": "GCC C++20" 91 | }, 92 | { 93 | "browse": { 94 | "limitSymbolsToIncludedHeaders": true 95 | }, 96 | "compilerPath": "C:/msys64/ucrt64/bin/g++.exe", 97 | "cppStandard": "c++23", 98 | "cStandard": "c23", 99 | "defines": [ 100 | "BS_THREAD_POOL_NATIVE_EXTENSIONS" 101 | ], 102 | "includePath": [ 103 | "${workspaceFolder}/**" 104 | ], 105 | "intelliSenseMode": "windows-gcc-x64", 106 | "name": "GCC C++23" 107 | }, 108 | { 109 | "browse": { 110 | "limitSymbolsToIncludedHeaders": true 111 | }, 112 | "compilerPath": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.42.34433/bin/Hostx64/x64/cl.exe", 113 | "cppStandard": "c++17", 114 | "cStandard": "c17", 115 | "defines": [ 116 | "BS_THREAD_POOL_NATIVE_EXTENSIONS" 117 | ], 118 | "includePath": [ 119 | "${workspaceFolder}/**" 120 | ], 121 | "intelliSenseMode": "windows-msvc-x64", 122 | "name": "MSVC C++17" 123 | }, 124 | { 125 | "browse": { 126 | "limitSymbolsToIncludedHeaders": true 127 | }, 128 | "compilerPath": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.42.34433/bin/Hostx64/x64/cl.exe", 129 | "cppStandard": "c++20", 130 | "cStandard": "c17", 131 | "defines": [ 132 | "BS_THREAD_POOL_NATIVE_EXTENSIONS" 133 | ], 134 | "includePath": [ 135 | "${workspaceFolder}/**" 136 | ], 137 | "intelliSenseMode": "windows-msvc-x64", 138 | "name": "MSVC C++20" 139 | }, 140 | { 141 | "browse": { 142 | "limitSymbolsToIncludedHeaders": true 143 | }, 144 | "compilerPath": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.42.34433/bin/Hostx64/x64/cl.exe", 145 | "cppStandard": "c++23", 146 | "cStandard": "c23", 147 | "defines": [ 148 | "BS_THREAD_POOL_NATIVE_EXTENSIONS" 149 | ], 150 | "includePath": [ 151 | "${workspaceFolder}/**" 152 | ], 153 | "intelliSenseMode": "windows-msvc-x64", 154 | "name": "MSVC C++23" 155 | } 156 | ], 157 | "version": 4 158 | } 159 | -------------------------------------------------------------------------------- /.vscode-windows/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "args": [], 5 | "cwd": "${workspaceFolder}${/}build", 6 | "name": "Build and debug (Clang C++17)", 7 | "preLaunchTask": "Build for debugging (Clang C++17)", 8 | "program": "${workspaceFolder}${/}build${/}${fileBasenameNoExtension}_debug-clang-cpp17", 9 | "request": "launch", 10 | "type": "lldb" 11 | }, 12 | { 13 | "args": [], 14 | "cwd": "${workspaceFolder}${/}build", 15 | "name": "Build and debug (Clang C++20)", 16 | "preLaunchTask": "Build for debugging (Clang C++20)", 17 | "program": "${workspaceFolder}${/}build${/}${fileBasenameNoExtension}_debug-clang-cpp20", 18 | "request": "launch", 19 | "type": "lldb" 20 | }, 21 | { 22 | "args": [], 23 | "cwd": "${workspaceFolder}${/}build", 24 | "name": "Build and debug (Clang C++23)", 25 | "preLaunchTask": "Build for debugging (Clang C++23)", 26 | "program": "${workspaceFolder}${/}build${/}${fileBasenameNoExtension}_debug-clang-cpp23", 27 | "request": "launch", 28 | "type": "lldb" 29 | }, 30 | { 31 | "args": [], 32 | "cwd": "${workspaceFolder}${/}build", 33 | "name": "Build and debug (GCC C++17)", 34 | "preLaunchTask": "Build for debugging (GCC C++17)", 35 | "program": "${workspaceFolder}${/}build${/}${fileBasenameNoExtension}_debug-gcc-cpp17", 36 | "request": "launch", 37 | "type": "cppdbg" 38 | }, 39 | { 40 | "args": [], 41 | "cwd": "${workspaceFolder}${/}build", 42 | "name": "Build and debug (GCC C++20)", 43 | "preLaunchTask": "Build for debugging (GCC C++20)", 44 | "program": "${workspaceFolder}${/}build${/}${fileBasenameNoExtension}_debug-gcc-cpp20", 45 | "request": "launch", 46 | "type": "cppdbg" 47 | }, 48 | { 49 | "args": [], 50 | "cwd": "${workspaceFolder}${/}build", 51 | "name": "Build and debug (GCC C++23)", 52 | "preLaunchTask": "Build for debugging (GCC C++23)", 53 | "program": "${workspaceFolder}${/}build${/}${fileBasenameNoExtension}_debug-gcc-cpp23", 54 | "request": "launch", 55 | "type": "cppdbg" 56 | }, 57 | { 58 | "args": [], 59 | "console": "integratedTerminal", 60 | "cwd": "${workspaceFolder}${/}build", 61 | "name": "Build and debug (MSVC C++17)", 62 | "preLaunchTask": "Build for debugging (MSVC C++17)", 63 | "program": "${workspaceFolder}${/}build${/}${fileBasenameNoExtension}_debug-msvc-cpp17", 64 | "request": "launch", 65 | "type": "cppvsdbg" 66 | }, 67 | { 68 | "args": [], 69 | "console": "integratedTerminal", 70 | "cwd": "${workspaceFolder}${/}build", 71 | "name": "Build and debug (MSVC C++20)", 72 | "preLaunchTask": "Build for debugging (MSVC C++20)", 73 | "program": "${workspaceFolder}${/}build${/}${fileBasenameNoExtension}_debug-msvc-cpp20", 74 | "request": "launch", 75 | "type": "cppvsdbg" 76 | }, 77 | { 78 | "args": [], 79 | "console": "integratedTerminal", 80 | "cwd": "${workspaceFolder}${/}build", 81 | "name": "Build and debug (MSVC C++23)", 82 | "preLaunchTask": "Build for debugging (MSVC C++23)", 83 | "program": "${workspaceFolder}${/}build${/}${fileBasenameNoExtension}_debug-msvc-cpp23", 84 | "request": "launch", 85 | "type": "cppvsdbg" 86 | } 87 | ], 88 | "version": "0.2.0" 89 | } 90 | -------------------------------------------------------------------------------- /.vscode-windows/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "tasks": [ 3 | { 4 | "args": [ 5 | "scripts/compile_cpp.py", 6 | "${file}", 7 | "-c=clang++", 8 | "-s=c++17", 9 | "-t=debug", 10 | "-v" 11 | ], 12 | "command": "python", 13 | "detail": "Compile active file using clang++ with warning and debugging flags.", 14 | "group": "build", 15 | "label": "Build for debugging (Clang C++17)", 16 | "presentation": { 17 | "clear": false, 18 | "echo": true, 19 | "focus": false, 20 | "panel": "shared", 21 | "reveal": "always", 22 | "revealProblems": "onProblem", 23 | "showReuseMessage": true 24 | }, 25 | "problemMatcher": [ 26 | "$gcc" 27 | ], 28 | "type": "cppbuild" 29 | }, 30 | { 31 | "args": [ 32 | "scripts/compile_cpp.py", 33 | "${file}", 34 | "-c=clang++", 35 | "-s=c++20", 36 | "-t=debug", 37 | "-v" 38 | ], 39 | "command": "python", 40 | "detail": "Compile active file using clang++ with warning and debugging flags.", 41 | "group": "build", 42 | "label": "Build for debugging (Clang C++20)", 43 | "presentation": { 44 | "clear": false, 45 | "echo": true, 46 | "focus": false, 47 | "panel": "shared", 48 | "reveal": "always", 49 | "revealProblems": "onProblem", 50 | "showReuseMessage": true 51 | }, 52 | "problemMatcher": [ 53 | "$gcc" 54 | ], 55 | "type": "cppbuild" 56 | }, 57 | { 58 | "args": [ 59 | "scripts/compile_cpp.py", 60 | "${file}", 61 | "-c=clang++", 62 | "-s=c++23", 63 | "-t=debug", 64 | "-v" 65 | ], 66 | "command": "python", 67 | "detail": "Compile active file using clang++ with warning and debugging flags.", 68 | "group": "build", 69 | "label": "Build for debugging (Clang C++23)", 70 | "presentation": { 71 | "clear": false, 72 | "echo": true, 73 | "focus": false, 74 | "panel": "shared", 75 | "reveal": "always", 76 | "revealProblems": "onProblem", 77 | "showReuseMessage": true 78 | }, 79 | "problemMatcher": [ 80 | "$gcc" 81 | ], 82 | "type": "cppbuild" 83 | }, 84 | { 85 | "args": [ 86 | "scripts/compile_cpp.py", 87 | "${file}", 88 | "-c=g++", 89 | "-s=c++17", 90 | "-t=debug", 91 | "-v" 92 | ], 93 | "command": "python", 94 | "detail": "Compile active file using g++ with warning and debugging flags.", 95 | "group": "build", 96 | "label": "Build for debugging (GCC C++17)", 97 | "presentation": { 98 | "clear": false, 99 | "echo": true, 100 | "focus": false, 101 | "panel": "shared", 102 | "reveal": "always", 103 | "revealProblems": "onProblem", 104 | "showReuseMessage": true 105 | }, 106 | "problemMatcher": [ 107 | "$gcc" 108 | ], 109 | "type": "cppbuild" 110 | }, 111 | { 112 | "args": [ 113 | "scripts/compile_cpp.py", 114 | "${file}", 115 | "-c=g++", 116 | "-s=c++20", 117 | "-t=debug", 118 | "-v" 119 | ], 120 | "command": "python", 121 | "detail": "Compile active file using g++ with warning and debugging flags.", 122 | "group": "build", 123 | "label": "Build for debugging (GCC C++20)", 124 | "presentation": { 125 | "clear": false, 126 | "echo": true, 127 | "focus": false, 128 | "panel": "shared", 129 | "reveal": "always", 130 | "revealProblems": "onProblem", 131 | "showReuseMessage": true 132 | }, 133 | "problemMatcher": [ 134 | "$gcc" 135 | ], 136 | "type": "cppbuild" 137 | }, 138 | { 139 | "args": [ 140 | "scripts/compile_cpp.py", 141 | "${file}", 142 | "-c=g++", 143 | "-s=c++23", 144 | "-t=debug", 145 | "-v" 146 | ], 147 | "command": "python", 148 | "detail": "Compile active file using g++ with warning and debugging flags.", 149 | "group": "build", 150 | "label": "Build for debugging (GCC C++23)", 151 | "presentation": { 152 | "clear": false, 153 | "echo": true, 154 | "focus": false, 155 | "panel": "shared", 156 | "reveal": "always", 157 | "revealProblems": "onProblem", 158 | "showReuseMessage": true 159 | }, 160 | "problemMatcher": [ 161 | "$gcc" 162 | ], 163 | "type": "cppbuild" 164 | }, 165 | { 166 | "args": [ 167 | "scripts/compile_cpp.py", 168 | "${file}", 169 | "-c=cl", 170 | "-s=c++17", 171 | "-t=debug", 172 | "-v" 173 | ], 174 | "command": "python", 175 | "detail": "Compile active file using cl with warning and debugging flags.", 176 | "group": "build", 177 | "label": "Build for debugging (MSVC C++17)", 178 | "presentation": { 179 | "clear": false, 180 | "echo": true, 181 | "focus": false, 182 | "panel": "shared", 183 | "reveal": "always", 184 | "revealProblems": "onProblem", 185 | "showReuseMessage": true 186 | }, 187 | "problemMatcher": [ 188 | "$msCompile" 189 | ], 190 | "type": "cppbuild" 191 | }, 192 | { 193 | "args": [ 194 | "scripts/compile_cpp.py", 195 | "${file}", 196 | "-c=cl", 197 | "-s=c++20", 198 | "-t=debug", 199 | "-v" 200 | ], 201 | "command": "python", 202 | "detail": "Compile active file using cl with warning and debugging flags.", 203 | "group": "build", 204 | "label": "Build for debugging (MSVC C++20)", 205 | "presentation": { 206 | "clear": false, 207 | "echo": true, 208 | "focus": false, 209 | "panel": "shared", 210 | "reveal": "always", 211 | "revealProblems": "onProblem", 212 | "showReuseMessage": true 213 | }, 214 | "problemMatcher": [ 215 | "$msCompile" 216 | ], 217 | "type": "cppbuild" 218 | }, 219 | { 220 | "args": [ 221 | "scripts/compile_cpp.py", 222 | "${file}", 223 | "-c=cl", 224 | "-s=c++23", 225 | "-t=debug", 226 | "-v" 227 | ], 228 | "command": "python", 229 | "detail": "Compile active file using cl with warning and debugging flags.", 230 | "group": "build", 231 | "label": "Build for debugging (MSVC C++23)", 232 | "presentation": { 233 | "clear": false, 234 | "echo": true, 235 | "focus": false, 236 | "panel": "shared", 237 | "reveal": "always", 238 | "revealProblems": "onProblem", 239 | "showReuseMessage": true 240 | }, 241 | "problemMatcher": [ 242 | "$msCompile" 243 | ], 244 | "type": "cppbuild" 245 | }, 246 | { 247 | "args": [ 248 | "scripts/compile_cpp.py", 249 | "${file}", 250 | "-c=clang++", 251 | "-s=c++17", 252 | "-t=release", 253 | "-v" 254 | ], 255 | "command": "python", 256 | "detail": "Compile active file using clang++ with warning and optimization flags.", 257 | "group": "build", 258 | "label": "Build optimized (Clang C++17)", 259 | "presentation": { 260 | "clear": false, 261 | "echo": true, 262 | "focus": false, 263 | "panel": "shared", 264 | "reveal": "always", 265 | "revealProblems": "onProblem", 266 | "showReuseMessage": true 267 | }, 268 | "problemMatcher": [ 269 | "$gcc" 270 | ], 271 | "type": "cppbuild" 272 | }, 273 | { 274 | "args": [ 275 | "scripts/compile_cpp.py", 276 | "${file}", 277 | "-c=clang++", 278 | "-s=c++20", 279 | "-t=release", 280 | "-v" 281 | ], 282 | "command": "python", 283 | "detail": "Compile active file using clang++ with warning and optimization flags.", 284 | "group": "build", 285 | "label": "Build optimized (Clang C++20)", 286 | "presentation": { 287 | "clear": false, 288 | "echo": true, 289 | "focus": false, 290 | "panel": "shared", 291 | "reveal": "always", 292 | "revealProblems": "onProblem", 293 | "showReuseMessage": true 294 | }, 295 | "problemMatcher": [ 296 | "$gcc" 297 | ], 298 | "type": "cppbuild" 299 | }, 300 | { 301 | "args": [ 302 | "scripts/compile_cpp.py", 303 | "${file}", 304 | "-c=clang++", 305 | "-s=c++23", 306 | "-t=release", 307 | "-v" 308 | ], 309 | "command": "python", 310 | "detail": "Compile active file using clang++ with warning and optimization flags.", 311 | "group": "build", 312 | "label": "Build optimized (Clang C++23)", 313 | "presentation": { 314 | "clear": false, 315 | "echo": true, 316 | "focus": false, 317 | "panel": "shared", 318 | "reveal": "always", 319 | "revealProblems": "onProblem", 320 | "showReuseMessage": true 321 | }, 322 | "problemMatcher": [ 323 | "$gcc" 324 | ], 325 | "type": "cppbuild" 326 | }, 327 | { 328 | "args": [ 329 | "scripts/compile_cpp.py", 330 | "${file}", 331 | "-c=g++", 332 | "-s=c++17", 333 | "-t=release", 334 | "-v" 335 | ], 336 | "command": "python", 337 | "detail": "Compile active file using g++ with warning and optimization flags.", 338 | "group": "build", 339 | "label": "Build optimized (GCC C++17)", 340 | "presentation": { 341 | "clear": false, 342 | "echo": true, 343 | "focus": false, 344 | "panel": "shared", 345 | "reveal": "always", 346 | "revealProblems": "onProblem", 347 | "showReuseMessage": true 348 | }, 349 | "problemMatcher": [ 350 | "$gcc" 351 | ], 352 | "type": "cppbuild" 353 | }, 354 | { 355 | "args": [ 356 | "scripts/compile_cpp.py", 357 | "${file}", 358 | "-c=g++", 359 | "-s=c++20", 360 | "-t=release", 361 | "-v" 362 | ], 363 | "command": "python", 364 | "detail": "Compile active file using g++ with warning and optimization flags.", 365 | "group": "build", 366 | "label": "Build optimized (GCC C++20)", 367 | "presentation": { 368 | "clear": false, 369 | "echo": true, 370 | "focus": false, 371 | "panel": "shared", 372 | "reveal": "always", 373 | "revealProblems": "onProblem", 374 | "showReuseMessage": true 375 | }, 376 | "problemMatcher": [ 377 | "$gcc" 378 | ], 379 | "type": "cppbuild" 380 | }, 381 | { 382 | "args": [ 383 | "scripts/compile_cpp.py", 384 | "${file}", 385 | "-c=g++", 386 | "-s=c++23", 387 | "-t=release", 388 | "-v" 389 | ], 390 | "command": "python", 391 | "detail": "Compile active file using g++ with warning and optimization flags.", 392 | "group": "build", 393 | "label": "Build optimized (GCC C++23)", 394 | "presentation": { 395 | "clear": false, 396 | "echo": true, 397 | "focus": false, 398 | "panel": "shared", 399 | "reveal": "always", 400 | "revealProblems": "onProblem", 401 | "showReuseMessage": true 402 | }, 403 | "problemMatcher": [ 404 | "$gcc" 405 | ], 406 | "type": "cppbuild" 407 | }, 408 | { 409 | "args": [ 410 | "scripts/compile_cpp.py", 411 | "${file}", 412 | "-c=cl", 413 | "-s=c++17", 414 | "-t=release", 415 | "-v" 416 | ], 417 | "command": "python", 418 | "detail": "Compile active file using cl with warning and optimization flags.", 419 | "group": "build", 420 | "label": "Build optimized (MSVC C++17)", 421 | "presentation": { 422 | "clear": false, 423 | "echo": true, 424 | "focus": false, 425 | "panel": "shared", 426 | "reveal": "always", 427 | "revealProblems": "onProblem", 428 | "showReuseMessage": true 429 | }, 430 | "problemMatcher": [ 431 | "$msCompile" 432 | ], 433 | "type": "cppbuild" 434 | }, 435 | { 436 | "args": [ 437 | "scripts/compile_cpp.py", 438 | "${file}", 439 | "-c=cl", 440 | "-s=c++20", 441 | "-t=release", 442 | "-v" 443 | ], 444 | "command": "python", 445 | "detail": "Compile active file using cl with warning and optimization flags.", 446 | "group": "build", 447 | "label": "Build optimized (MSVC C++20)", 448 | "presentation": { 449 | "clear": false, 450 | "echo": true, 451 | "focus": false, 452 | "panel": "shared", 453 | "reveal": "always", 454 | "revealProblems": "onProblem", 455 | "showReuseMessage": true 456 | }, 457 | "problemMatcher": [ 458 | "$msCompile" 459 | ], 460 | "type": "cppbuild" 461 | }, 462 | { 463 | "args": [ 464 | "scripts/compile_cpp.py", 465 | "${file}", 466 | "-c=cl", 467 | "-s=c++23", 468 | "-t=release", 469 | "-v" 470 | ], 471 | "command": "python", 472 | "detail": "Compile active file using cl with warning and optimization flags.", 473 | "group": "build", 474 | "label": "Build optimized (MSVC C++23)", 475 | "presentation": { 476 | "clear": false, 477 | "echo": true, 478 | "focus": false, 479 | "panel": "shared", 480 | "reveal": "always", 481 | "revealProblems": "onProblem", 482 | "showReuseMessage": true 483 | }, 484 | "problemMatcher": [ 485 | "$msCompile" 486 | ], 487 | "type": "cppbuild" 488 | }, 489 | { 490 | "args": [ 491 | "scripts/compile_cpp.py", 492 | "${file}", 493 | "-c=clang++", 494 | "-s=c++17", 495 | "-t=release", 496 | "-r", 497 | "-v" 498 | ], 499 | "command": "python", 500 | "detail": "Compile active file using clang++ with warning and optimization flags and run the program.", 501 | "group": "test", 502 | "label": "Build optimized and run (Clang C++17)", 503 | "presentation": { 504 | "clear": false, 505 | "echo": true, 506 | "focus": false, 507 | "panel": "shared", 508 | "reveal": "always", 509 | "revealProblems": "onProblem", 510 | "showReuseMessage": true 511 | } 512 | }, 513 | { 514 | "args": [ 515 | "scripts/compile_cpp.py", 516 | "${file}", 517 | "-c=clang++", 518 | "-s=c++20", 519 | "-t=release", 520 | "-r", 521 | "-v" 522 | ], 523 | "command": "python", 524 | "detail": "Compile active file using clang++ with warning and optimization flags and run the program.", 525 | "group": "test", 526 | "label": "Build optimized and run (Clang C++20)", 527 | "presentation": { 528 | "clear": false, 529 | "echo": true, 530 | "focus": false, 531 | "panel": "shared", 532 | "reveal": "always", 533 | "revealProblems": "onProblem", 534 | "showReuseMessage": true 535 | } 536 | }, 537 | { 538 | "args": [ 539 | "scripts/compile_cpp.py", 540 | "${file}", 541 | "-c=clang++", 542 | "-s=c++23", 543 | "-t=release", 544 | "-r", 545 | "-v" 546 | ], 547 | "command": "python", 548 | "detail": "Compile active file using clang++ with warning and optimization flags and run the program.", 549 | "group": "test", 550 | "label": "Build optimized and run (Clang C++23)", 551 | "presentation": { 552 | "clear": false, 553 | "echo": true, 554 | "focus": false, 555 | "panel": "shared", 556 | "reveal": "always", 557 | "revealProblems": "onProblem", 558 | "showReuseMessage": true 559 | } 560 | }, 561 | { 562 | "args": [ 563 | "scripts/compile_cpp.py", 564 | "${file}", 565 | "-c=g++", 566 | "-s=c++17", 567 | "-t=release", 568 | "-r", 569 | "-v" 570 | ], 571 | "command": "python", 572 | "detail": "Compile active file using g++ with warning and optimization flags and run the program.", 573 | "group": "test", 574 | "label": "Build optimized and run (GCC C++17)", 575 | "presentation": { 576 | "clear": false, 577 | "echo": true, 578 | "focus": false, 579 | "panel": "shared", 580 | "reveal": "always", 581 | "revealProblems": "onProblem", 582 | "showReuseMessage": true 583 | } 584 | }, 585 | { 586 | "args": [ 587 | "scripts/compile_cpp.py", 588 | "${file}", 589 | "-c=g++", 590 | "-s=c++20", 591 | "-t=release", 592 | "-r", 593 | "-v" 594 | ], 595 | "command": "python", 596 | "detail": "Compile active file using g++ with warning and optimization flags and run the program.", 597 | "group": "test", 598 | "label": "Build optimized and run (GCC C++20)", 599 | "presentation": { 600 | "clear": false, 601 | "echo": true, 602 | "focus": false, 603 | "panel": "shared", 604 | "reveal": "always", 605 | "revealProblems": "onProblem", 606 | "showReuseMessage": true 607 | } 608 | }, 609 | { 610 | "args": [ 611 | "scripts/compile_cpp.py", 612 | "${file}", 613 | "-c=g++", 614 | "-s=c++23", 615 | "-t=release", 616 | "-r", 617 | "-v" 618 | ], 619 | "command": "python", 620 | "detail": "Compile active file using g++ with warning and optimization flags and run the program.", 621 | "group": "test", 622 | "label": "Build optimized and run (GCC C++23)", 623 | "presentation": { 624 | "clear": false, 625 | "echo": true, 626 | "focus": false, 627 | "panel": "shared", 628 | "reveal": "always", 629 | "revealProblems": "onProblem", 630 | "showReuseMessage": true 631 | } 632 | }, 633 | { 634 | "args": [ 635 | "scripts/compile_cpp.py", 636 | "${file}", 637 | "-c=cl", 638 | "-s=c++17", 639 | "-t=release", 640 | "-r", 641 | "-v" 642 | ], 643 | "command": "python", 644 | "detail": "Compile active file using cl with warning and optimization flags and run the program.", 645 | "group": "test", 646 | "label": "Build optimized and run (MSVC C++17)", 647 | "presentation": { 648 | "clear": false, 649 | "echo": true, 650 | "focus": false, 651 | "panel": "shared", 652 | "reveal": "always", 653 | "revealProblems": "onProblem", 654 | "showReuseMessage": true 655 | } 656 | }, 657 | { 658 | "args": [ 659 | "scripts/compile_cpp.py", 660 | "${file}", 661 | "-c=cl", 662 | "-s=c++20", 663 | "-t=release", 664 | "-r", 665 | "-v" 666 | ], 667 | "command": "python", 668 | "detail": "Compile active file using cl with warning and optimization flags and run the program.", 669 | "group": "test", 670 | "label": "Build optimized and run (MSVC C++20)", 671 | "presentation": { 672 | "clear": false, 673 | "echo": true, 674 | "focus": false, 675 | "panel": "shared", 676 | "reveal": "always", 677 | "revealProblems": "onProblem", 678 | "showReuseMessage": true 679 | } 680 | }, 681 | { 682 | "args": [ 683 | "scripts/compile_cpp.py", 684 | "${file}", 685 | "-c=cl", 686 | "-s=c++23", 687 | "-t=release", 688 | "-r", 689 | "-v" 690 | ], 691 | "command": "python", 692 | "detail": "Compile active file using cl with warning and optimization flags and run the program.", 693 | "group": "test", 694 | "label": "Build optimized and run (MSVC C++23)", 695 | "presentation": { 696 | "clear": false, 697 | "echo": true, 698 | "focus": false, 699 | "panel": "shared", 700 | "reveal": "always", 701 | "revealProblems": "onProblem", 702 | "showReuseMessage": true 703 | } 704 | }, 705 | { 706 | "args": [ 707 | "scripts/clear_folder.py", 708 | "../build" 709 | ], 710 | "command": "python", 711 | "detail": "Delete all files in the build folder.", 712 | "group": "test", 713 | "label": "Clear build folder", 714 | "presentation": { 715 | "clear": false, 716 | "echo": true, 717 | "focus": false, 718 | "panel": "shared", 719 | "reveal": "always", 720 | "revealProblems": "onProblem", 721 | "showReuseMessage": true 722 | }, 723 | "type": "shell" 724 | }, 725 | { 726 | "args": [ 727 | "scripts/clear_folder.py", 728 | "../temp" 729 | ], 730 | "command": "python", 731 | "detail": "Delete all files in the temp folder.", 732 | "group": "test", 733 | "label": "Clear temp folder", 734 | "presentation": { 735 | "clear": false, 736 | "echo": true, 737 | "focus": false, 738 | "panel": "shared", 739 | "reveal": "always", 740 | "revealProblems": "onProblem", 741 | "showReuseMessage": true 742 | }, 743 | "type": "shell" 744 | }, 745 | { 746 | "args": [ 747 | "scripts/test_all.py" 748 | ], 749 | "command": "python", 750 | "detail": "Compile and run the test program with all available compilers and all relevant C++ standards.", 751 | "group": "test", 752 | "label": "Run all tests", 753 | "presentation": { 754 | "clear": false, 755 | "echo": true, 756 | "focus": false, 757 | "panel": "shared", 758 | "reveal": "always", 759 | "revealProblems": "onProblem", 760 | "showReuseMessage": true 761 | }, 762 | "type": "shell" 763 | } 764 | ], 765 | "version": "2.0.0" 766 | } 767 | -------------------------------------------------------------------------------- /CITATION.bib: -------------------------------------------------------------------------------- 1 | @article{Shoshany2024_ThreadPool, 2 | archiveprefix = {arXiv}, 3 | author = {Barak Shoshany}, 4 | doi = {10.1016/j.softx.2024.101687}, 5 | eprint = {2105.00613}, 6 | journal = {SoftwareX}, 7 | pages = {101687}, 8 | title = {{A C++17 Thread Pool for High-Performance Scientific Computing}}, 9 | url = {https://www.sciencedirect.com/science/article/pii/S235271102400058X}, 10 | volume = {26}, 11 | year = {2024} 12 | } 13 | -------------------------------------------------------------------------------- /CITATION.cff: -------------------------------------------------------------------------------- 1 | authors: 2 | - email: baraksh@gmail.com 3 | family-names: Shoshany 4 | given-names: Barak 5 | orcid: https://orcid.org/0000-0003-2222-127X 6 | cff-version: 1.2.0 7 | doi: 10.1016/j.softx.2024.101687 8 | license: MIT 9 | message: If you use this library in published research, please cite it as follows. 10 | preferred-citation: 11 | authors: 12 | - family-names: Shoshany 13 | given-names: Barak 14 | doi: 10.1016/j.softx.2024.101687 15 | journal: SoftwareX 16 | start: 101687 17 | title: A C++17 Thread Pool for High-Performance Scientific Computing 18 | type: article 19 | url: https://www.sciencedirect.com/science/article/pii/S235271102400058X 20 | volume: 26 21 | year: 2024 22 | repository-code: https://github.com/bshoshany/thread-pool 23 | title: A C++17 Thread Pool for High-Performance Scientific Computing 24 | type: software 25 | url: https://github.com/bshoshany/thread-pool 26 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Barak Shoshany 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /compile_cpp.yaml: -------------------------------------------------------------------------------- 1 | # A list of macros to define when compiling the source files. 2 | defines: [BS_THREAD_POOL_TEST_IMPORT_MODULE, BS_THREAD_POOL_IMPORT_STD, BS_THREAD_POOL_NATIVE_EXTENSIONS] 3 | # A map of flags to pass to each compiler. The compiler should be one of [cl, clang++, g++]. The flags should be a list of strings. 4 | flags: 5 | cl: [/W4] 6 | clang++: [-Wall, -Wextra, -Wconversion, -Wsign-conversion, -Wpedantic, -Wshadow, -Weffc++, -march=native, -fcolor-diagnostics, -fansi-escape-codes, -stdlib=libc++] 7 | g++: [-Wall, -Wextra, -Wconversion, -Wpedantic, -Wshadow, -Wuseless-cast, -march=native, -fdiagnostics-color=always] 8 | # A list of include folders. 9 | includes: [include] 10 | # A map of C++20 modules in the format "module_name: [module_path, dependent files, ...]". Will only be used in C++20 or C++23 mode. The dependent files are any files that the module depends on, and are only used to determine whether the module needs to be recompiled. 11 | modules: 12 | BS.thread_pool: [modules/BS.thread_pool.cppm, include/BS_thread_pool.hpp] 13 | # The output folder for the compiled files. 14 | output: build/ 15 | # A list of arguments to pass to the program if running it after compilation. 16 | pass_args: [] 17 | # A map of paths to the standard library modules for each OS and compiler combination (C++23 only). The OS should be one of [Darwin, Linux, Windows]. This is currently only officially supported by MSVC with Microsoft STL and LLVM Clang (NOT Apple Clang) with LLVM libc++. It is not supported by GCC with any standard library, or any compiler with GNU libstdc++. Use "auto" to determine the path automatically if possible. 18 | std_module: 19 | Darwin: 20 | clang++: auto 21 | Linux: 22 | clang++: auto 23 | Windows: 24 | cl: auto 25 | clang++: auto 26 | -------------------------------------------------------------------------------- /modules/BS.thread_pool.cppm: -------------------------------------------------------------------------------- 1 | /** 2 | * ██████ ███████ ████████ ██ ██ ██████ ███████ █████ ██████ ██████ ██████ ██████ ██ 3 | * ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ 4 | * ██████ ███████ ██ ███████ ██████ █████ ███████ ██ ██ ██████ ██ ██ ██ ██ ██ 5 | * ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ 6 | * ██████ ███████ ██ ██ ██ ██ ██ ███████ ██ ██ ██████ ███████ ██ ██████ ██████ ███████ 7 | * 8 | * @file BS.thread_pool.cppm 9 | * @author Barak Shoshany (baraksh@gmail.com) (https://baraksh.com/) 10 | * @version 5.0.0 11 | * @date 2024-12-19 12 | * @copyright Copyright (c) 2024 Barak Shoshany. Licensed under the MIT license. If you found this project useful, please consider starring it on GitHub! If you use this library in software of any kind, please provide a link to the GitHub repository https://github.com/bshoshany/thread-pool in the source code and documentation. If you use this library in published research, please cite it as follows: Barak Shoshany, "A C++17 Thread Pool for High-Performance Scientific Computing", doi:10.1016/j.softx.2024.101687, SoftwareX 26 (2024) 101687, arXiv:2105.00613 13 | * 14 | * @brief `BS::thread_pool`: a fast, lightweight, modern, and easy-to-use C++17/C++20/C++23 thread pool library. This module file wraps the header file BS_thread_pool.hpp inside a C++20 module so it can be imported using `import BS.thread_pool`. 15 | */ 16 | 17 | module; 18 | 19 | // A macro indicating to the library that it is being imported as a module, as well as the version of the module file, which must match the version of the header file. 20 | #define BS_THREAD_POOL_MODULE 5, 0, 0 21 | 22 | #include "BS_thread_pool.hpp" 23 | 24 | export module BS.thread_pool; 25 | 26 | export namespace BS { 27 | using BS::binary_semaphore; 28 | using BS::common_index_type_t; 29 | using BS::counting_semaphore; 30 | using BS::light_thread_pool; 31 | using BS::multi_future; 32 | using BS::pause_thread_pool; 33 | using BS::pr; 34 | using BS::priority_t; 35 | using BS::priority_thread_pool; 36 | using BS::synced_stream; 37 | using BS::this_thread; 38 | using BS::thread_pool; 39 | using BS::thread_pool_import_std; 40 | using BS::thread_pool_module; 41 | using BS::thread_pool_native_extensions; 42 | using BS::thread_pool_version; 43 | using BS::tp; 44 | using BS::version; 45 | using BS::wait_deadlock; 46 | using BS::wdc_thread_pool; 47 | 48 | #ifdef BS_THREAD_POOL_NATIVE_EXTENSIONS 49 | using BS::get_os_process_affinity; 50 | using BS::get_os_process_priority; 51 | using BS::os_process_priority; 52 | using BS::os_thread_priority; 53 | using BS::set_os_process_affinity; 54 | using BS::set_os_process_priority; 55 | #endif 56 | } // namespace BS 57 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.pyright] 2 | analyzeUnannotatedFunctions = true 3 | deprecateTypingAliases = true 4 | disableBytesTypePromotions = true 5 | enableExperimentalFeatures = false 6 | enableReachabilityAnalysis = true 7 | enableTypeIgnoreComments = true 8 | extraPaths = ["."] 9 | pythonPlatform = "All" 10 | pythonVersion = "3.13" 11 | reportAbstractUsage = "error" 12 | reportArgumentType = "error" 13 | reportAssertAlwaysTrue = "error" 14 | reportAssertTypeFailure = "error" 15 | reportAssignmentType = "error" 16 | reportAttributeAccessIssue = "error" 17 | reportCallInDefaultInitializer = "error" 18 | reportCallIssue = "error" 19 | reportConstantRedefinition = "error" 20 | reportDeprecated = "error" 21 | reportDuplicateImport = "error" 22 | reportFunctionMemberAccess = "error" 23 | reportGeneralTypeIssues = "error" 24 | reportImplicitOverride = "error" 25 | reportImplicitStringConcatenation = "error" 26 | reportImportCycles = "error" 27 | reportIncompatibleMethodOverride = "error" 28 | reportIncompatibleVariableOverride = "error" 29 | reportIncompleteStub = "error" 30 | reportInconsistentConstructor = "error" 31 | reportInconsistentOverload = "error" 32 | reportIndexIssue = "error" 33 | reportInvalidStringEscapeSequence = "error" 34 | reportInvalidStubStatement = "error" 35 | reportInvalidTypeArguments = "error" 36 | reportInvalidTypeForm = "error" 37 | reportInvalidTypeVarUse = "error" 38 | reportMatchNotExhaustive = "error" 39 | reportMissingImports = "error" 40 | reportMissingModuleSource = "error" 41 | reportMissingParameterType = "error" 42 | reportMissingTypeArgument = "error" 43 | reportMissingTypeStubs = "error" 44 | reportNoOverloadImplementation = "error" 45 | reportOperatorIssue = "none" 46 | reportOptionalCall = "error" 47 | reportOptionalContextManager = "error" 48 | reportOptionalIterable = "error" 49 | reportOptionalMemberAccess = "error" 50 | reportOptionalOperand = "error" 51 | reportOptionalSubscript = "error" 52 | reportOverlappingOverload = "error" 53 | reportPossiblyUnboundVariable = "error" 54 | reportPrivateImportUsage = "error" 55 | reportPrivateUsage = "error" 56 | reportPropertyTypeMismatch = "none" 57 | reportRedeclaration = "error" 58 | reportReturnType = "error" 59 | reportSelfClsParameterName = "error" 60 | reportShadowedImports = "error" 61 | reportTypeCommentUsage = "error" 62 | reportTypedDictNotRequiredAccess = "error" 63 | reportUnboundVariable = "error" 64 | reportUndefinedVariable = "error" 65 | reportUnhashable = "error" 66 | reportUninitializedInstanceVariable = "error" 67 | reportUnknownArgumentType = "error" 68 | reportUnknownLambdaType = "error" 69 | reportUnknownMemberType = "none" 70 | reportUnknownParameterType = "error" 71 | reportUnknownVariableType = "error" 72 | reportUnnecessaryCast = "error" 73 | reportUnnecessaryComparison = "error" 74 | reportUnnecessaryContains = "error" 75 | reportUnnecessaryIsInstance = "error" 76 | reportUnnecessaryTypeIgnoreComment = "error" 77 | reportUnsupportedDunderAll = "error" 78 | reportUntypedBaseClass = "error" 79 | reportUntypedClassDecorator = "error" 80 | reportUntypedFunctionDecorator = "error" 81 | reportUntypedNamedTuple = "error" 82 | reportUnusedCallResult = "error" 83 | reportUnusedClass = "warning" 84 | reportUnusedCoroutine = "error" 85 | reportUnusedExcept = "error" 86 | reportUnusedExpression = "error" 87 | reportUnusedFunction = "warning" 88 | reportUnusedImport = "warning" 89 | reportUnusedVariable = "warning" 90 | reportWildcardImportFromLibrary = "error" 91 | strictDictionaryInference = true 92 | strictListInference = true 93 | strictParameterNoneValue = true 94 | strictSetInference = true 95 | typeCheckingMode = "strict" 96 | useLibraryCodeForTypes = true 97 | 98 | [tool.ruff] 99 | indent-width = 4 100 | line-length = 320 101 | target-version = "py313" 102 | 103 | [tool.ruff.format] 104 | docstring-code-format = false 105 | docstring-code-line-length = "dynamic" 106 | indent-style = "space" 107 | line-ending = "lf" 108 | quote-style = "double" 109 | skip-magic-trailing-comma = false 110 | 111 | [tool.ruff.lint] 112 | dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" 113 | fixable = ["ALL"] 114 | ignore = [ 115 | "BLE001", 116 | "C901", 117 | "D200", 118 | "D203", 119 | "D205", 120 | "D212", 121 | "D400", 122 | "D402", 123 | "D415", 124 | "E501", 125 | "INP001", 126 | "N814", 127 | "N999", 128 | "PLR0912", 129 | "PLR0913", 130 | "PLR2004", 131 | "RUF009", 132 | "S310", 133 | "S602", 134 | "S603", 135 | "S607", 136 | "SIM108", 137 | "SLF001", 138 | "T201", 139 | "TCH003", 140 | "TD002", 141 | "TD003", 142 | "UP015", 143 | ] 144 | select = ["ALL"] 145 | unfixable = [] 146 | 147 | [tool.ruff.lint.per-file-ignores] 148 | "Interactive*" = ["ALL"] 149 | 150 | [tool.pylint.main] 151 | analyse-fallback-blocks = false 152 | clear-cache-post-run = false 153 | exit-zero = false 154 | extension-pkg-allow-list = [] 155 | extension-pkg-whitelist = [] 156 | fail-on = "" 157 | fail-under = 10 158 | from-stdin = false 159 | ignore-paths = [] 160 | ignore-patterns = [] 161 | ignored-modules = [] 162 | init-hook = "" 163 | jobs = 0 164 | limit-inference-results = 100 165 | load-plugins = [] 166 | persistent = true 167 | prefer-stubs = true 168 | py-version = "3.13" 169 | recursive = false 170 | source-roots = [] 171 | suggestion-mode = true 172 | unsafe-load-any-extension = false 173 | 174 | [tool.pylint.basic] 175 | argument-naming-style = "snake_case" 176 | argument-rgx = "" 177 | attr-naming-style = "snake_case" 178 | attr-rgx = "" 179 | bad-names = [] 180 | bad-names-rgxs = "" 181 | class-attribute-naming-style = "any" 182 | class-attribute-rgx = "" 183 | class-const-naming-style = "UPPER_CASE" 184 | class-const-rgx = "" 185 | class-naming-style = "PascalCase" 186 | class-rgx = "" 187 | const-naming-style = "UPPER_CASE" 188 | const-rgx = "" 189 | docstring-min-length = -1 190 | function-naming-style = "snake_case" 191 | function-rgx = "" 192 | good-names = ["_"] 193 | good-names-rgxs = "" 194 | include-naming-hint = true 195 | inlinevar-naming-style = "any" 196 | inlinevar-rgx = "" 197 | method-naming-style = "snake_case" 198 | method-rgx = "" 199 | module-naming-style = "snake_case" 200 | module-rgx = "" 201 | name-group = [] 202 | no-docstring-rgx = "" 203 | property-classes = ["abc.abstractproperty"] 204 | typealias-rgx = "" 205 | typevar-rgx = "" 206 | variable-naming-style = "snake_case" 207 | variable-rgx = "" 208 | 209 | [tool.pylint.classes] 210 | check-protected-access-in-special-methods = true 211 | defining-attr-methods = [ 212 | "__init__", 213 | "__new__", 214 | "__post_init__", 215 | "asyncSetUp", 216 | "setUp", 217 | ] 218 | exclude-protected = [ 219 | "_asdict", 220 | "_fields", 221 | "_make", 222 | "_replace", 223 | "_source", 224 | "os._exit", 225 | ] 226 | valid-classmethod-first-arg = ["cls"] 227 | valid-metaclass-classmethod-first-arg = ["mcs"] 228 | 229 | [tool.pylint.design] 230 | exclude-too-few-public-methods = [] 231 | ignored-parents = [] 232 | max-args = 5 233 | max-attributes = 7 234 | max-bool-expr = 5 235 | max-branches = 12 236 | max-locals = 15 237 | max-parents = 7 238 | max-public-methods = 20 239 | max-returns = 6 240 | max-statements = 50 241 | min-public-methods = 2 242 | 243 | [tool.pylint.exceptions] 244 | overgeneral-exceptions = ["builtins.BaseException", "builtins.Exception"] 245 | 246 | [tool.pylint.format] 247 | expected-line-ending-format = "LF" 248 | ignore-long-lines = "^\\s*(# )??$" 249 | indent-after-paren = 4 250 | indent-string = " " 251 | max-line-length = 1024 252 | max-module-lines = 8192 253 | single-line-class-stmt = false 254 | single-line-if-stmt = false 255 | 256 | [tool.pylint.imports] 257 | allow-any-import-level = [] 258 | allow-reexport-from-package = false 259 | allow-wildcard-with-all = false 260 | deprecated-modules = [] 261 | ext-import-graph = "" 262 | import-graph = "" 263 | int-import-graph = "" 264 | known-standard-library = [] 265 | known-third-party = [] 266 | preferred-modules = [] 267 | 268 | [tool.pylint.logging] 269 | logging-format-style = "new" 270 | logging-modules = ["logging"] 271 | 272 | [tool.pylint."messages control"] 273 | confidence = [] 274 | disable = [ 275 | "broad-exception-caught", 276 | "consider-using-enumerate", 277 | "expression-not-assigned", 278 | "import-error", 279 | "invalid-unary-operand-type", 280 | "missing-module-docstring", 281 | "named-expr-without-context", 282 | "not-callable", 283 | "pointless-statement", 284 | "protected-access", 285 | "too-few-public-methods", 286 | "too-many-arguments", 287 | "too-many-boolean-expressions", 288 | "too-many-branches", 289 | "too-many-instance-attributes", 290 | "too-many-locals", 291 | "too-many-nested-blocks", 292 | "too-many-public-methods", 293 | "ungrouped-imports", 294 | "use-implicit-booleaness-not-comparison-to-string", 295 | "use-implicit-booleaness-not-comparison-to-zero", 296 | "wrong-import-order", 297 | "wrong-import-position", 298 | ] 299 | enable = ["all"] 300 | 301 | [tool.pylint.method_args] 302 | timeout-methods = [ 303 | "requests.api.delete", 304 | "requests.api.get", 305 | "requests.api.head", 306 | "requests.api.options", 307 | "requests.api.patch", 308 | "requests.api.post", 309 | "requests.api.put", 310 | "requests.api.request", 311 | ] 312 | 313 | [tool.pylint.miscellaneous] 314 | notes = ["TODO"] 315 | notes-rgx = "" 316 | 317 | [tool.pylint.refactoring] 318 | max-nested-blocks = 5 319 | never-returning-functions = ["argparse.parse_error", "sys.exit"] 320 | suggest-join-with-non-empty-separator = true 321 | 322 | [tool.pylint.reports] 323 | evaluation = "max(0, 0 if fatal else 10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10))" 324 | msg-template = "" 325 | output-format = "text" 326 | reports = true 327 | score = true 328 | 329 | [tool.pylint.similarities] 330 | ignore-comments = true 331 | ignore-docstrings = true 332 | ignore-imports = true 333 | ignore-signatures = true 334 | min-similarity-lines = 4 335 | 336 | [tool.pylint.spelling] 337 | max-spelling-suggestions = 4 338 | spelling-dict = "" 339 | spelling-ignore-comment-directives = "fmt: on,fmt: off,noqa:,noqa,nosec,isort:skip,mypy:" 340 | spelling-ignore-words = "" 341 | spelling-private-dict-file = "" 342 | spelling-store-unknown-words = false 343 | 344 | [tool.pylint.typecheck] 345 | contextmanager-decorators = ["contextlib.contextmanager"] 346 | generated-members = [] 347 | ignore-mixin-members = true 348 | ignore-none = true 349 | ignore-on-opaque-inference = false 350 | ignored-checks-for-mixins = [ 351 | "attribute-defined-outside-init", 352 | "no-member", 353 | "not-async-context-manager", 354 | "not-context-manager", 355 | ] 356 | ignored-classes = [ 357 | "_thread._local", 358 | "argparse.Namespace", 359 | "optparse.Values", 360 | "thread._local", 361 | ] 362 | missing-member-hint = true 363 | missing-member-hint-distance = 1 364 | missing-member-max-choices = 1 365 | mixin-class-rgx = ".*[Mm]ixin" 366 | signature-mutators = [] 367 | 368 | [tool.pylint.variables] 369 | additional-builtins = [] 370 | allow-global-unused-variables = true 371 | allowed-redefined-builtins = [] 372 | callbacks = ["_cb", "cb_"] 373 | dummy-variables-rgx = "^_.*" 374 | ignored-argument-names = "^_.*" 375 | init-import = true 376 | redefining-builtins-modules = [ 377 | "builtins", 378 | "future.builtins", 379 | "io", 380 | "past.builtins", 381 | "six.moves", 382 | ] 383 | -------------------------------------------------------------------------------- /scripts/clear_folder.py: -------------------------------------------------------------------------------- 1 | """ 2 | ██████ ███████ ████████ ██ ██ ██████ ███████ █████ ██████ ██████ ██████ ██████ ██ 3 | ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ 4 | ██████ ███████ ██ ███████ ██████ █████ ███████ ██ ██ ██████ ██ ██ ██ ██ ██ 5 | ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ 6 | ██████ ███████ ██ ██ ██ ██ ██ ███████ ██ ██ ██████ ███████ ██ ██████ ██████ ███████ 7 | 8 | `BS::thread_pool`: a fast, lightweight, modern, and easy-to-use C++17/C++20/C++23 thread pool library 9 | v5.0.0 (2024-12-19) 10 | By Barak Shoshany 11 | Copyright (c) 2024 Barak Shoshany. Licensed under the MIT license. If you found this project useful, please consider starring it on GitHub! If you use this library in software of any kind, please provide a link to the GitHub repository https://github.com/bshoshany/thread-pool in the source code and documentation. If you use this library in published research, please cite it as follows: Barak Shoshany, "A C++17 Thread Pool for High-Performance Scientific Computing", doi:10.1016/j.softx.2024.101687, SoftwareX 26 (2024) 101687, arXiv:2105.00613 12 | 13 | This Python script is used in the library's development environment to clear all files a folder. It is not part of the library itself. 14 | """ 15 | 16 | import argparse 17 | import importlib 18 | import importlib.util 19 | import pathlib 20 | import sys 21 | from importlib.machinery import ModuleSpec 22 | from types import ModuleType 23 | 24 | send2trash_spec: ModuleSpec | None = importlib.util.find_spec("send2trash") 25 | if send2trash_spec is not None: 26 | # Install with `pip install send2trash`. 27 | send2trash: ModuleType = importlib.import_module("send2trash") 28 | 29 | def delete_files_in_folder(folder_path: pathlib.Path) -> None: 30 | """Recursively delete all files in a folder.""" 31 | for child in folder_path.iterdir(): 32 | if child.is_file(): 33 | send2trash.send2trash(paths=child) 34 | else: 35 | delete_files_in_folder(child) 36 | send2trash.send2trash(folder_path) 37 | else: 38 | print("Note: Module send2trash not found; deleting files permanently.") 39 | 40 | def delete_files_in_folder(folder_path: pathlib.Path) -> None: 41 | """Fallback function in case `send2trash` is not installed.""" 42 | for child in folder_path.iterdir(): 43 | if child.is_file(): 44 | child.unlink() 45 | else: 46 | delete_files_in_folder(child) 47 | folder_path.rmdir() 48 | 49 | 50 | parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) 51 | _ = parser.add_argument("folder", help="the folder to clear (relative to this script's location)") 52 | parsed_args: argparse.Namespace = parser.parse_args(args=None if len(sys.argv) > 1 else ["--help"]) 53 | 54 | folder: pathlib.Path = (pathlib.Path(__file__).parent / parsed_args.folder).resolve() 55 | if not folder.exists(): 56 | print(f"Folder {folder} does not exist; creating empty.") 57 | else: 58 | try: 59 | delete_files_in_folder(folder) 60 | folder.mkdir() 61 | print(f"Folder {folder} successfully cleared.") 62 | except Exception as exc: 63 | sys.exit(f"Error clearing folder {folder}: {exc}") 64 | -------------------------------------------------------------------------------- /scripts/compile_cpp.py: -------------------------------------------------------------------------------- 1 | """ 2 | ██████ ███████ ████████ ██ ██ ██████ ███████ █████ ██████ ██████ ██████ ██████ ██ 3 | ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ 4 | ██████ ███████ ██ ███████ ██████ █████ ███████ ██ ██ ██████ ██ ██ ██ ██ ██ 5 | ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ 6 | ██████ ███████ ██ ██ ██ ██ ██ ███████ ██ ██ ██████ ███████ ██ ██████ ██████ ███████ 7 | 8 | `BS::thread_pool`: a fast, lightweight, modern, and easy-to-use C++17/C++20/C++23 thread pool library 9 | v5.0.0 (2024-12-19) 10 | By Barak Shoshany 11 | Copyright (c) 2024 Barak Shoshany. Licensed under the MIT license. If you found this project useful, please consider starring it on GitHub! If you use this library in software of any kind, please provide a link to the GitHub repository https://github.com/bshoshany/thread-pool in the source code and documentation. If you use this library in published research, please cite it as follows: Barak Shoshany, "A C++17 Thread Pool for High-Performance Scientific Computing", doi:10.1016/j.softx.2024.101687, SoftwareX 26 (2024) 101687, arXiv:2105.00613 12 | 13 | This Python script can be used to compile simple C++ programs (with only a few source and/or header files) using a variety of compilers, C++ standards, and other options. It also includes support for C++20 modules and C++23 Standard Library modules. It is used in the thread pool library's development environment to compile and run the test program using different compilers and C++ standards. It is not part of the library itself, but users of the library may find it useful, especially if they wish to use the library as a C++20 module. 14 | """ 15 | 16 | import argparse 17 | import os 18 | import pathlib 19 | import platform 20 | import shutil 21 | import subprocess 22 | import sys 23 | import time 24 | 25 | import yaml # Install with `pip install pyyaml`. 26 | 27 | separator: str = "=" * 60 28 | 29 | 30 | class Args: 31 | """A class to collect the command line arguments with proper type checking.""" 32 | 33 | def __init__(self, parsed_ns: argparse.Namespace) -> None: 34 | """Store the parsed arguments.""" 35 | self.files: list[str] = parsed_ns.files 36 | self.arch: str = parsed_ns.arch 37 | self.as_module: bool = parsed_ns.as_module 38 | self.compiler: str | None = parsed_ns.compiler 39 | self.define: list[str] = parsed_ns.define if parsed_ns.define is not None else [] 40 | self.flag: list[str] = parsed_ns.flag if parsed_ns.flag is not None else [] 41 | self.ignore_yaml: bool = parsed_ns.ignore_yaml 42 | self.include: list[str] = parsed_ns.include if parsed_ns.include is not None else [] 43 | self.module: list[str] = parsed_ns.module if parsed_ns.module is not None else [] 44 | self.output: str | None = parsed_ns.output 45 | self.pass_args: list[str] = parsed_ns.pass_args if parsed_ns.pass_args is not None else [] 46 | self.run: bool = parsed_ns.run 47 | self.std_module: str | None = parsed_ns.std_module 48 | self.std: str = parsed_ns.std 49 | self.type: str = parsed_ns.type 50 | self.verbose: bool = parsed_ns.verbose 51 | 52 | 53 | # Parse the command-line arguments. 54 | parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) 55 | _ = parser.add_argument("files", nargs="+", help="the source file(s) to compile") 56 | _ = parser.add_argument("-a", "--arch", choices=["amd64", "arm64"], default="amd64", help="the target architecture (MSVC only)") 57 | _ = parser.add_argument("-c", "--compiler", choices=["cl", "clang++", "g++"], help="which compiler to use (auto determined if not specified)") 58 | _ = parser.add_argument("-d", "--define", action="append", help="macros to define (use multiple times if more than one) [in addition to those in compile_cpp.yaml]") 59 | _ = parser.add_argument("-f", "--flag", action="append", help="extra compiler flags to add (use multiple times if more than one) [in addition to those in compile_cpp.yaml]") 60 | _ = parser.add_argument("-g", "--ignore-yaml", action="store_true", help="ignore the compile_cpp.yaml file") 61 | _ = parser.add_argument("-i", "--include", action="append", help="the include folder to use (use multiple times if more than one) [in addition to those in compile_cpp.yaml]") 62 | _ = parser.add_argument("-l", "--as-module", action="store_true", help="Compile file as module") 63 | _ = parser.add_argument("-m", "--module", action="append", help='C++20 module files to use if desired, in the format "module_name=module_file,dependent_files,..." (use multiple times if more than one) [in addition to those in compile_cpp.yaml]') 64 | _ = parser.add_argument("-o", "--output", help="the output folder (end with / to create, taken from compile_cpp.yaml if not specified) and/or executable name (auto determined if not specified)") 65 | _ = parser.add_argument("-p", "--pass", action="append", dest="pass_args", help="pass command line arguments to the compiled program when running it, if -r is specified (use multiple times if more than one) [in addition to those in compile_cpp.yaml]") 66 | _ = parser.add_argument("-r", "--run", action="store_true", help="run the program after compiling it") 67 | _ = parser.add_argument("-s", "--std", choices=["c++17", "c++20", "c++23"], default="c++23", help="which C++ standard to use") 68 | _ = parser.add_argument("-t", "--type", choices=["debug", "release"], default="debug", help="whether to compile in debug or release mode") 69 | _ = parser.add_argument("-u", "--std-module", help="path to the standard library module (C++23 only, taken from compile_cpp.yaml if not specified, use 'auto' to auto-detect, 'disable' to explicitly disable)") 70 | _ = parser.add_argument("-v", "--verbose", action="store_true", help="whether to print this script's diagnostic messages") 71 | args = Args(parser.parse_args(args=None if len(sys.argv) > 1 else ["--help"])) 72 | 73 | 74 | def print_if_verbose(message: str) -> None: 75 | """Print a message, but only if the verbose flag is set.""" 76 | if args.verbose: 77 | print(message) 78 | 79 | 80 | # Collect the full path(s) to the source file(s). 81 | source_paths: list[pathlib.Path] = [pathlib.Path(file).resolve() for file in args.files] 82 | 83 | # Determine the compiler if it is not given. 84 | compiler: str = "" 85 | vs_pwsh_path: str = r"C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\Launch-VsDevShell.ps1" 86 | if args.compiler is not None: 87 | compiler = args.compiler 88 | else: # noqa: PLR5501 89 | # On Windows, we default to MSVC if the Visual Studio Developer PowerShell script exists, otherwise we fall back to Clang, and then GCC. 90 | if platform.system() == "Windows": 91 | if pathlib.Path(vs_pwsh_path).exists(): 92 | compiler = "cl" 93 | elif shutil.which("clang++") is not None: 94 | compiler = "clang++" 95 | elif shutil.which("g++") is not None: 96 | compiler = "g++" 97 | # On Linux, we default to GCC if it is available, otherwise we fall back to Clang. 98 | elif platform.system() == "Linux": 99 | if shutil.which("g++") is not None: 100 | compiler = "g++" 101 | elif shutil.which("clang++") is not None: 102 | compiler = "clang++" 103 | # On macOS, we just check if Clang is available. 104 | elif platform.system() == "Darwin" and shutil.which("clang++") is not None: 105 | compiler = "clang++" 106 | if compiler == "": 107 | sys.exit("Error: No compiler found!") 108 | 109 | # If a file named `compile_cpp.yaml` exists in the current working directory, read the configuration from it. All options are added to those from the command line, except the output file/folder and path to the standard library module, which are only used if not provided in the command line. Note that all folders should be specified relative to the current working directory. 110 | defines: list[str] = args.define[:] 111 | flags: list[str] = args.flag[:] 112 | includes: list[str] = args.include[:] 113 | modules: dict[str, list[str]] = {name: files.split(",") for module in args.module for name, files in (module.split("="),)} 114 | output: str | None = args.output 115 | pass_args: list[str] = args.pass_args[:] 116 | compile_yaml: pathlib.Path = pathlib.Path.cwd() / "compile_cpp.yaml" 117 | std_module: str | None = args.std_module 118 | 119 | if not args.ignore_yaml and compile_yaml.exists(): 120 | with compile_yaml.open("r") as file: 121 | compile_config = yaml.safe_load(file) 122 | if "defines" in compile_config: 123 | defines.extend(compile_config["defines"]) 124 | if "flags" in compile_config and compiler in compile_config["flags"]: 125 | flags.extend(compile_config["flags"][compiler]) 126 | if "includes" in compile_config: 127 | includes.extend(compile_config["includes"]) 128 | if "modules" in compile_config: 129 | modules.update(compile_config["modules"]) 130 | if output is None and "output" in compile_config: 131 | output = compile_config["output"] 132 | if "pass_args" in compile_config: 133 | pass_args.extend(compile_config["pass_args"]) 134 | if std_module is None and "std_module" in compile_config and platform.system() in compile_config["std_module"] and compiler in compile_config["std_module"][platform.system()] and len(compile_config["std_module"][platform.system()][compiler]) > 0: 135 | std_module = compile_config["std_module"][platform.system()][compiler] 136 | 137 | # Importing the C++ Standard Library is only available in C++23 mode, and currently only officially supported by MSVC and Clang. If "disable" is specified for the standard library module, we skip it; this is used to avoid infinite recursion. 138 | use_std_module: bool = not (std_module is None or std_module == "disable" or args.std != "c++23" or compiler not in ["cl", "clang++"]) 139 | 140 | if use_std_module and std_module is not None: 141 | modules = {"std": [std_module], **modules} 142 | 143 | # Figure out the path to the MSVC or Clang std module, if relevant. 144 | if use_std_module and "std" in modules and modules["std"][0].strip() == "auto": 145 | success: bool = False 146 | if platform.system() == "Windows" and compiler == "cl": 147 | vc_version_path: pathlib.Path = pathlib.Path(r"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt") 148 | if vc_version_path.exists(): 149 | with vc_version_path.open("r", encoding="utf-8") as vc_version_file: 150 | vc_version: str = vc_version_file.read().strip() 151 | vc_tools_path: str = rf"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\{vc_version}" 152 | modules["std"][0] = rf"{vc_tools_path}\modules\std.ixx" 153 | success = True 154 | elif compiler == "clang++": 155 | # Note: The Clang `std` module is only available with libc++. 156 | if platform.system() == "Windows": 157 | # On Windows, libc++ is most likely installed via MSYS2, so the `std` module should be at `C:\msys64\clang64\share\libc++\v1\std.cppm`. We calculate it relative to the path where `clang++.exe` is located, in case the MSYS2 installation folder is different. 158 | clang_path: str | None = shutil.which("clang++") 159 | if clang_path: 160 | std_path: pathlib.Path = pathlib.Path(clang_path).parent.parent / "share" / "libc++" / "v1" / "std.cppm" 161 | if std_path.exists(): 162 | modules["std"][0] = str(std_path.absolute()) 163 | success = True 164 | elif platform.system() == "Darwin": 165 | # On macOS, the `std` module should be at `/usr/local/Cellar/llvm//share/libc++/v1/std.cppm`. We use `find` to locate it without needing to know the exact LLVM version. 166 | llvm_path: str = subprocess.check_output(["find", "/usr/local/Cellar/llvm", "-name", "std.cppm"], text=True).strip() 167 | if llvm_path: 168 | modules["std"][0] = llvm_path 169 | success = True 170 | elif platform.system() == "Linux": 171 | # On Linux, the `std` module should be at `/usr/lib/llvm-/share/libc++/v1/std.cppm`. We use `find` to locate it without needing to know the exact LLVM version. 172 | llvm_path: str = subprocess.check_output(["find", "/usr/lib", "-name", "std.cppm"], text=True).strip() 173 | if llvm_path: 174 | modules["std"][0] = llvm_path 175 | success = True 176 | if not success: 177 | sys.exit('Error: "auto" specified for the standard library module path, but the script could not locate it. Please specify the path manually.') 178 | 179 | # Determine the name of the executable file and the build folder. 180 | executable_path: pathlib.Path | None = None 181 | build_folder: pathlib.Path 182 | auto_executable: bool = False 183 | if output is not None: 184 | # Calculate the output path relative to the current working directory. Note that if the path is absolute, `pathlib` will automatically use the absolute path instead of a relative path. 185 | output_path: pathlib.Path = (pathlib.Path.cwd() / output).resolve() 186 | if output.endswith(("/", "\\")) or output_path.is_dir(): 187 | # If the output path is a directory, we use it as the build folder, and automatically determine the name of the executable file. 188 | build_folder = output_path.resolve() 189 | auto_executable = True 190 | elif output_path.is_absolute(): 191 | # If the output path is an absolute path to a file, the build folder is the file's folder. 192 | build_folder = output_path.parent.resolve() 193 | executable_path = output_path 194 | else: 195 | # If the output path is just a file name, the build folder is the current working directory by default. 196 | build_folder = pathlib.Path.cwd() 197 | executable_path = build_folder / output_path 198 | else: 199 | # If there is no output path at all, the build folder is the current working directory by default, and we automatically determine the name of the executable file. 200 | build_folder = pathlib.Path.cwd() 201 | auto_executable = True 202 | 203 | # If the user did not provide an output file name, we use the name of the first source file, appending the compiler, mode, and C++ standard. 204 | short_compiler: str = "clang" if compiler == "clang++" else "gcc" if compiler == "g++" else "msvc" 205 | suffix: str = f"{args.type}-{short_compiler}-cpp{args.std[-2:]}" 206 | if auto_executable: 207 | extension: str = ".exe" if platform.system() == "Windows" else "" 208 | executable: str = f"{source_paths[0].stem}_{suffix}{extension}" 209 | executable_path = build_folder / executable 210 | if executable_path is None: 211 | sys.exit("Error: Could not determine executable file!") 212 | 213 | # Determine if the build folder exists, and create it if not. 214 | if not pathlib.Path(build_folder).exists(): 215 | pathlib.Path(build_folder).mkdir() 216 | 217 | # If modules are specified, pre-compile them by calling this script recursively, unless the current file is itself a module. As a special case, if the std module is used, we add it even if the current file is a module, in case the module itself wants to import the std module. 218 | module_paths: dict[str, list[pathlib.Path]] = {} 219 | if not args.as_module: 220 | module_paths = {name: [(pathlib.Path.cwd() / file).resolve() for file in files] for name, files in modules.items()} 221 | elif use_std_module and "std" in modules: 222 | module_paths = {"std": [(pathlib.Path.cwd() / modules["std"][0]).resolve()]} 223 | if len(modules) > 0 and (args.std in ["c++20", "c++23"]): 224 | for name, paths in module_paths.items(): 225 | module_flags: list[str] = args.flag[:] 226 | module_extension: str 227 | if compiler == "cl": 228 | module_extension = ".ifc" 229 | module_flags = ["/interface", "/TP", "/c"] 230 | elif compiler == "clang++": 231 | module_extension = ".pcm" 232 | module_flags = ["--precompile", "-Wno-include-angled-in-module-purview", "-Wno-reserved-module-identifier", "-xc++-module"] 233 | else: # compiler == "g++" 234 | # Note: Creating an object file can be disabled with `-fmodule-only`, and it doesn't seem like the object file is actually needed, only the `.gcm` file. However, we create the object file anyway so we can check if the module is up to date, since there appears to be no way to control the name of the `.gcm` file. 235 | module_extension = ".o" 236 | module_flags = ["-fmodules-ts", "-xc++", "-c", f"-fmodule-mapper=|@g++-mapper-server -r{build_folder}"] 237 | # Only the first file on the list needs to be compiled; the rest are dependencies that are only used to check if the compiled module is up to date. 238 | module_file: pathlib.Path = paths[0] 239 | module_output_path: pathlib.Path = build_folder / f"{module_file.stem}_module_{suffix}{module_extension}" 240 | if compiler == "cl": 241 | flags.extend(["/reference", f"{name}={module_output_path.resolve()}"]) 242 | if name != "std" or not args.as_module: 243 | flags.append(str(build_folder / f"{module_output_path.stem}.obj")) 244 | elif compiler == "clang++": 245 | flags.append(f"-fmodule-file={name}={module_output_path.resolve()}") 246 | else: # compiler == "g++" 247 | flags.append("-fmodules-ts") 248 | flags.append(f"-fmodule-mapper=|@g++-mapper-server -r{build_folder}") 249 | if module_output_path.exists(): 250 | module_output_mod: float = module_output_path.stat().st_mtime 251 | if not any((path.exists() and path.stat().st_mtime > module_output_mod) for path in paths): 252 | print_if_verbose(f'Module "{name}" is up to date, skipping compilation.') 253 | continue 254 | try: 255 | command: list[str] = [ 256 | "python" if platform.system() == "Windows" else "python3", 257 | str(pathlib.Path(__file__).resolve()), 258 | str(module_file), 259 | f"-o={module_output_path.resolve()}", 260 | f"-a={args.arch}", 261 | f"-c={compiler}", 262 | f"-s={args.std}", 263 | f"-t={args.type}", 264 | # Note: Not adding the extra options from the configuration file, since they will be added by the script anyway. 265 | *[f"-d={define}" for define in args.define], 266 | *[f"-i={include}" for include in args.include], 267 | *[f"-f={flag}" for flag in (args.flag + module_flags)], 268 | # If compiling the `std` module itself, we need to pass `-u disable` to avoid infinite recursion. Otherwise, we pass along the specified module path if it exists. 269 | *(["-u=disable"] if name == "std" else [f"-u={std_module}"] if std_module is not None else []), 270 | "-l", 271 | *(["-v"] if args.verbose else []), 272 | ] 273 | print_if_verbose(separator) 274 | print_if_verbose(f'Compiling module "{name}" with command: {subprocess.list2cmdline(command)}') 275 | compile_result: subprocess.CompletedProcess[str] = subprocess.run( 276 | args=command, 277 | check=False, 278 | text=True, 279 | ) 280 | if compile_result.returncode != 0: 281 | sys.exit(f"Module compilation failed with return code: {compile_result.returncode}.") 282 | except Exception as exc: 283 | sys.exit(f"Could not compile module due to exception: {exc}.") 284 | print_if_verbose("Compiling program...") 285 | 286 | # Collect the full paths to the include folders, relative to the current working directory. 287 | include_paths: list[pathlib.Path] = [(pathlib.Path.cwd() / folder).resolve() for folder in includes] 288 | 289 | # On macOS, make sure we are using Homebrew Clang, if available, instead of Apple Clang, which does not support C++20 modules. 290 | compiler_path: str | None 291 | if compiler == "clang++" and platform.system() == "Darwin": 292 | compiler_path = "/usr/local/opt/llvm/bin/clang++" 293 | if not pathlib.Path(compiler_path).exists(): 294 | compiler_path = shutil.which(compiler) 295 | else: 296 | compiler_path = shutil.which(compiler) 297 | 298 | # Determine the command to execute based on the chosen compiler and parameters. 299 | command: list[str] 300 | if compiler == "clang++": 301 | command = [ 302 | compiler_path if compiler_path is not None else compiler, 303 | *flags, 304 | *[str(path.resolve()) for path in source_paths], 305 | f"-std={args.std}", 306 | "-g3" if args.type == "debug" else "-O3", 307 | "-o", 308 | str(executable_path), 309 | *([] if platform.system() == "Windows" else ["-pthread"]), 310 | *[item for include in [["-I", str(path.resolve())] for path in include_paths] for item in include], 311 | *([f"-D{define}" for define in defines]), 312 | ] 313 | elif compiler == "g++": 314 | if len(modules) > 0 and (args.std in ["c++20", "c++23"]): 315 | print_if_verbose( 316 | "NOTE: GCC v14.2.0 appears to have an internal compiler error when compiling programs containing modules with any optimization flags other than -Og enabled. Until this is fixed, if you wish to use compiler optimizations, please either include the library as a header file or use a different compiler.", 317 | ) 318 | command = [ 319 | compiler_path if compiler_path is not None else compiler, 320 | *flags, 321 | *[str(path.resolve()) for path in source_paths], 322 | f"-std={args.std}", 323 | "-ggdb3" if args.type == "debug" else "-O3" if not (len(modules) > 0 and (args.std in ["c++20", "c++23"])) else "-Og", 324 | "-o", 325 | str(executable_path), 326 | *([] if platform.system() == "Windows" else ["-pthread"]), 327 | *[item for include in [["-I", str(path.resolve())] for path in include_paths] for item in include], 328 | *([f"-D{define}" for define in defines]), 329 | ] 330 | else: # compiler == "cl" 331 | command = [ 332 | compiler_path if compiler_path is not None else compiler, 333 | *flags, 334 | *[str(path.resolve()) for path in source_paths], 335 | f"/std:{"c++latest" if args.std == "c++23" else args.std}", 336 | *(["/Zi", f"/Fd:{executable_path.with_suffix(".pdb")}"] if args.type == "debug" else ["/O2"]), 337 | *([f"/Fe:{executable_path}"] if not args.as_module else ["/ifcOutput", str(executable_path)]), 338 | f"/Fo:{executable_path.with_suffix(".obj")}", 339 | *[item for include in [["/I", str(path.resolve())] for path in include_paths] for item in include], 340 | "/permissive-", 341 | "/EHsc", 342 | "/nologo", 343 | "/Zc:__cplusplus", 344 | *([f"/D{define}" for define in defines]), 345 | ] 346 | 347 | # For MSVC we also need to invoke the Visual Studio Developer PowerShell script. 348 | if compiler == "cl": 349 | command = ["pwsh.exe", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", f"& '{vs_pwsh_path}' -Arch {args.arch} -HostArch {args.arch} | Out-Null; {subprocess.list2cmdline(command)}"] 350 | 351 | print_if_verbose(separator) 352 | print_if_verbose(f"Compiler: {compiler}") 353 | print_if_verbose(f"C++ Standard: {args.std.upper()}") 354 | print_if_verbose(f"Type: {args.type.title()}") 355 | print_if_verbose(f"Source file(s): [{", ".join([str(path) for path in source_paths])}]") 356 | print_if_verbose(f"Defines: [{", ".join(defines)}]") 357 | print_if_verbose(f"Flags: [{", ".join(flags)}]") 358 | print_if_verbose(f"Includes: [{(", ".join([str(path) for path in include_paths]))}]") 359 | if args.std in ["c++20", "c++23"]: 360 | print_if_verbose(f"Modules: [{", ".join(f"{name}={path[0]}" for name, path in module_paths.items()) if not args.as_module else ""}]") 361 | else: 362 | print_if_verbose("Modules: ") 363 | print_if_verbose(f"Build folder: {build_folder}") 364 | print_if_verbose(f"Binary file: {executable_path.name}") 365 | print_if_verbose(f"Command: {subprocess.list2cmdline(command)}") 366 | 367 | # Perform the actual compilation. 368 | print_if_verbose(separator) 369 | print_if_verbose("Compiling...") 370 | success = False 371 | try: 372 | compile_start: float = time.perf_counter() 373 | compile_result: subprocess.CompletedProcess[str] = subprocess.run( 374 | args=command, 375 | check=False, 376 | text=True, 377 | ) 378 | if compile_result.returncode == 0: 379 | print_if_verbose(f"Compilation completed successfully in {time.perf_counter() - compile_start:.2f} seconds.") 380 | success = True 381 | else: 382 | sys.exit(f"Compilation failed with return code: {compile_result.returncode}.") 383 | except Exception as exc: 384 | sys.exit(f"Could not compile due to exception: {exc}.") 385 | 386 | # If there were compilation errors, delete the executable file if it exists, so the IDE won't mistakenly run the old version anyway. 387 | if not success and executable_path.exists(): 388 | executable_path.unlink() 389 | 390 | if args.run: 391 | # We run the program in the build folder. 392 | os.chdir(build_folder) 393 | print_if_verbose(f"Running program{f" with arguments {" ".join(pass_args)}" if len(pass_args) > 0 else ""}...") 394 | print_if_verbose(separator) 395 | try: 396 | run_start: float = time.perf_counter() 397 | run_result: subprocess.CompletedProcess[str] = subprocess.run( 398 | args=[executable_path, *pass_args], 399 | check=False, 400 | text=True, 401 | ) 402 | print_if_verbose(separator) 403 | if run_result.returncode == 0: 404 | print_if_verbose(f"Program executed successfully in {time.perf_counter() - run_start:.2f} seconds.") 405 | else: 406 | sys.exit(f"Program failed with return code: {run_result.returncode}.") 407 | except Exception as exc: 408 | print_if_verbose(separator) 409 | sys.exit(f"Could not run program due to exception: {exc}.") 410 | -------------------------------------------------------------------------------- /scripts/test_all.py: -------------------------------------------------------------------------------- 1 | """ 2 | ██████ ███████ ████████ ██ ██ ██████ ███████ █████ ██████ ██████ ██████ ██████ ██ 3 | ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ 4 | ██████ ███████ ██ ███████ ██████ █████ ███████ ██ ██ ██████ ██ ██ ██ ██ ██ 5 | ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ 6 | ██████ ███████ ██ ██ ██ ██ ██ ███████ ██ ██ ██████ ███████ ██ ██████ ██████ ███████ 7 | 8 | `BS::thread_pool`: a fast, lightweight, modern, and easy-to-use C++17/C++20/C++23 thread pool library 9 | v5.0.0 (2024-12-19) 10 | By Barak Shoshany 11 | Copyright (c) 2024 Barak Shoshany. Licensed under the MIT license. If you found this project useful, please consider starring it on GitHub! If you use this library in software of any kind, please provide a link to the GitHub repository https://github.com/bshoshany/thread-pool in the source code and documentation. If you use this library in published research, please cite it as follows: Barak Shoshany, "A C++17 Thread Pool for High-Performance Scientific Computing", doi:10.1016/j.softx.2024.101687, SoftwareX 26 (2024) 101687, arXiv:2105.00613 12 | 13 | This Python script is used in the library's development environment to compile and run the test program using all possible combinations of compilers and C++ standards available in the system, in order to test compatibility. 14 | """ 15 | 16 | import argparse 17 | import pathlib 18 | import platform 19 | import shutil 20 | import subprocess 21 | import sys 22 | import time 23 | 24 | parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) 25 | _ = parser.add_argument("--compile-only", action="store_true", help="only check that the program compiles successfully with all compilers, without running it") 26 | parsed_args: argparse.Namespace = parser.parse_args() 27 | 28 | 29 | def print_message(message: str) -> None: 30 | """Print a message with indicator characters to differentiate it from messages from the compile script.""" 31 | print(f"\n >>>>> {message} <<<<<\n") 32 | 33 | 34 | # Determine which compilers are available. 35 | vs_pwsh_path: str = r"C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\Launch-VsDevShell.ps1" 36 | compilers: list[str] = [] 37 | if pathlib.Path(vs_pwsh_path).exists(): 38 | compilers.append("cl") 39 | if shutil.which("clang++") is not None: 40 | compilers.append("clang++") 41 | # On macOS, g++ is by default just an alias for clang++, so we skip it. 42 | if shutil.which("g++") is not None and platform.system() != "Darwin": 43 | compilers.append("g++") 44 | 45 | # Compile using all available compilers using all relevant C++ standards. 46 | standards: list[str] = ["c++17", "c++20", "c++23"] 47 | workspace_path: pathlib.Path = pathlib.Path(__file__).parent.parent.resolve() 48 | source_path: pathlib.Path = workspace_path / "tests" / "BS_thread_pool_test.cpp" 49 | script_path: pathlib.Path = workspace_path / "scripts" / "compile_cpp.py" 50 | try: 51 | compile_start: float = time.perf_counter() 52 | for compiler in compilers: 53 | for std in standards: 54 | print_message(f"Compiling with {compiler} using {std.upper()} standard...") 55 | warnings_as_errors: list[str] = ["-f/WX"] if compiler == "cl" else ["-f-Werror"] 56 | command: list[str] = [ 57 | "python" if platform.system() == "Windows" else "python3", 58 | str(script_path.resolve()), 59 | str(source_path.resolve()), 60 | "-c", 61 | compiler, 62 | "-s", 63 | std, 64 | "-t", 65 | "release", 66 | *warnings_as_errors, 67 | *(["-r"] if not parsed_args.compile_only else []), 68 | "-p", 69 | "stdout", 70 | "-p", 71 | "log", 72 | "-p", 73 | "tests", 74 | "-v", 75 | ] 76 | compile_result: subprocess.CompletedProcess[str] = subprocess.run( 77 | args=command, 78 | check=False, 79 | text=True, 80 | ) 81 | if compile_result.returncode != 0: 82 | print_message("Compilation failed, aborting script!") 83 | sys.exit(compile_result.returncode) 84 | except Exception as exc: 85 | print_message(f"Could not compile due to exception: {exc}.") 86 | sys.exit(1) 87 | print_message(f"All tests completed successfully in {time.perf_counter() - compile_start:.2f} seconds.") 88 | --------------------------------------------------------------------------------