Skip to content

Commit 547c557

Browse files
Version 0.0.8 (#32)
* project structure refactor - all header files go to include/concurrencpp directory, TSAN tests to test directory * sources were formatted using clang-format * move to modern cmake * partial move to ctest * CI/CD pipeline with github actions on Windows, Linux and macOS (uses xcode 12.2, clang fails with ICE) * readme improvements Co-authored-by: friendlyanon <1736896+friendlyanon@users.noreply.github.com> Co-authored-by: friendlyanon <friendlyanon@users.noreply.github.com>
1 parent fbc8c47 commit 547c557

File tree

215 files changed

+13266
-13219
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

215 files changed

+13266
-13219
lines changed

clang-format renamed to .clang-format

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,10 @@ SpacesInContainerLiterals: 'true'
5151
SpacesInParentheses: 'false'
5252
SpacesInSquareBrackets: 'false'
5353
Standard: Cpp11
54-
54+
ColumnLimit: 165
55+
IndentWidth: 4
56+
BinPackArguments: 'false'
57+
BinPackParameters: 'false'
58+
AllowAllArgumentsOnNextLine: 'false'
59+
NamespaceIndentation: All
5560
...

.github/workflows/ci.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Continuous Integration
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
pull_request:
9+
branches:
10+
- master
11+
12+
workflow_dispatch: ~
13+
14+
env:
15+
CMAKE_VERSION: 3.18.4
16+
NINJA_VERSION: 1.10.1
17+
CTEST_OUTPUT_ON_FAILURE: 1
18+
NINJA_STATUS: '[%f/%t %o/sec] '
19+
20+
jobs:
21+
tests:
22+
strategy:
23+
matrix:
24+
conf:
25+
- name: Ubuntu (Clang 10 - TSAN)
26+
os: ubuntu-20.04
27+
cc: clang-10
28+
cxx: clang++-10
29+
tsan: YES
30+
31+
- name: Ubuntu (Clang 10 - no TSAN)
32+
os: ubuntu-20.04
33+
cc: clang-10
34+
cxx: clang++-10
35+
tsan: NO
36+
37+
- name: macOS (Clang 10 - no TSAN)
38+
os: macos-latest
39+
cc: clang
40+
cxx: clang++
41+
tsan: NO
42+
43+
- name: Windows (Visual Studio Enterprise 2019)
44+
os: windows-latest
45+
cc: cl
46+
cxx: cl
47+
tsan: NO
48+
49+
name: ${{ matrix.conf.name }}
50+
51+
runs-on: ${{ matrix.conf.os }}
52+
53+
env:
54+
CC: ${{ matrix.conf.cc }}
55+
CXX: ${{ matrix.conf.cxx }}
56+
57+
steps:
58+
- uses: actions/checkout@v1
59+
60+
- uses: friendlyanon/fetch-core-count@v1
61+
id: cores
62+
63+
- run: cmake -E make_directory build/tools
64+
65+
- name: Install CMake and Ninja
66+
id: tools
67+
working-directory: build/tools
68+
run: cmake -D RUNNER_OS=${{ runner.os }}
69+
-P ../../cmake/ciToolsUpdate.cmake
70+
71+
- name: Combine CI variables
72+
id: args
73+
shell: cmake -P {0}
74+
run: >
75+
message([==[::set-output name=args::${{ matrix.conf.os }}
76+
"${{ steps.tools.outputs.cmake }}"
77+
"${{ steps.tools.outputs.ninja }}"
78+
${{ steps.cores.outputs.plus_one }}]==])
79+
80+
- name: Build examples
81+
run: cmake -P cmake/ciBuild.cmake -- example build/example
82+
${{ steps.args.outputs.args }}
83+
84+
- name: Build tests
85+
id: build_tests
86+
continue-on-error: ${{ startsWith(matrix.conf.os, 'macos') }}
87+
run: cmake -P cmake/ciBuild.cmake -- test build/test
88+
${{ steps.args.outputs.args }}
89+
-D ENABLE_THREAD_SANITIZER:BOOL=${{ matrix.conf.tsan }}
90+
91+
- name: Run tests
92+
continue-on-error: ${{ startsWith(matrix.conf.os, 'macos') }}
93+
if: steps.build_tests.outcome == 'success'
94+
working-directory: build/test
95+
shell: cmake -P {0}
96+
run: >
97+
include(../../cmake/exec.cmake)
98+
99+
exec("${{ steps.tools.outputs.ctest }}" -C Release -V
100+
-j ${{ steps.cores.outputs.plus_one }})

.gitignore

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,14 @@
3737

3838
# End of https://www.toptal.com/developers/gitignore/api/c++
3939

40-
#Others
40+
# Others
4141
.vs
4242

43-
#Specific directories
44-
/build
45-
/msvc_intermediate
43+
# Specific directories
44+
build/
45+
msvc_intermediate/
4646
out/
47+
48+
# CLion
49+
.idea/
50+
**/cmake-build-*/

CMakeLists.txt

Lines changed: 106 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,113 @@
11
cmake_minimum_required(VERSION 3.16)
2-
project(concurrencpp)
32

4-
set(CMAKE_CXX_STANDARD 20)
3+
project(concurrencpp
4+
VERSION 0.0.8
5+
LANGUAGES CXX)
56

6-
if (MSVC)
7-
add_compile_options(/W3)
8-
else()
9-
add_compile_options(-Wall -Wextra)
7+
include(cmake/coroutineOptions.cmake)
108

11-
option(CONCURRENCPP_ENABLE_TSAN "Enables thread-sanitizer checks" OFF)
12-
if (CONCURRENCPP_ENABLE_TSAN)
13-
add_compile_options(-fsanitize=thread)
14-
add_link_options(-fsanitize=thread)
15-
endif()
9+
# ---- Warning guard ----
10+
11+
# Protect dependents from this project's warnings if the guard isn't disabled
12+
set(concurrencpp_warning_guard "SYSTEM")
13+
if(concurrencpp_INCLUDE_WITHOUT_SYSTEM)
14+
set(concurrencpp_warning_guard "")
1615
endif()
1716

18-
add_subdirectory(concurrencpp)
19-
add_subdirectory(tests)
20-
add_subdirectory(sandbox)
21-
add_subdirectory(examples)
17+
# ---- Declare library ----
2218

23-
if (CONCURRENCPP_ENABLE_TSAN)
24-
add_subdirectory(thread_sanitizers)
25-
endif()
19+
set(concurrencpp_sources
20+
source/executors/executor.cpp
21+
source/executors/manual_executor.cpp
22+
source/executors/thread_executor.cpp
23+
source/executors/thread_pool_executor.cpp
24+
source/executors/worker_thread_executor.cpp
25+
source/results/promises.cpp
26+
source/results/result_core.cpp
27+
source/runtime/runtime.cpp
28+
source/threads/thread.cpp
29+
source/timers/timer.cpp
30+
source/timers/timer_queue.cpp)
31+
32+
set(concurrencpp_headers
33+
include/concurrencpp/concurrencpp.h
34+
include/concurrencpp/errors.h
35+
include/concurrencpp/forward_declerations.h
36+
include/concurrencpp/platform_defs.h
37+
include/concurrencpp/executors/constants.h
38+
include/concurrencpp/executors/derivable_executor.h
39+
include/concurrencpp/executors/executor.h
40+
include/concurrencpp/executors/executor_all.h
41+
include/concurrencpp/executors/inline_executor.h
42+
include/concurrencpp/executors/manual_executor.h
43+
include/concurrencpp/executors/thread_executor.h
44+
include/concurrencpp/executors/thread_pool_executor.h
45+
include/concurrencpp/executors/worker_thread_executor.h
46+
include/concurrencpp/results/constants.h
47+
include/concurrencpp/results/executor_exception.h
48+
include/concurrencpp/results/make_result.h
49+
include/concurrencpp/results/promises.h
50+
include/concurrencpp/results/result.h
51+
include/concurrencpp/results/result_awaitable.h
52+
include/concurrencpp/results/result_core.h
53+
include/concurrencpp/results/result_fwd_declerations.h
54+
include/concurrencpp/results/when_result.h
55+
include/concurrencpp/runtime/constants.h
56+
include/concurrencpp/runtime/runtime.h
57+
include/concurrencpp/threads/thread.h
58+
include/concurrencpp/timers/constants.h
59+
include/concurrencpp/timers/timer.h
60+
include/concurrencpp/timers/timer_queue.h
61+
include/concurrencpp/utils/bind.h)
62+
63+
add_library(concurrencpp STATIC ${concurrencpp_headers} ${concurrencpp_sources})
64+
add_library(concurrencpp::concurrencpp ALIAS concurrencpp)
65+
66+
target_include_directories(concurrencpp
67+
${concurrencpp_warning_guard}
68+
PUBLIC
69+
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>")
70+
71+
target_compile_features(concurrencpp PUBLIC cxx_std_20)
72+
73+
target_coroutine_options(concurrencpp)
74+
75+
find_library(LIBRT NAMES rt DOC "Path to the Real Time shared library")
76+
target_link_libraries(concurrencpp PUBLIC "$<$<BOOL:${LIBRT}>:${LIBRT}>")
77+
78+
# ---- Install ----
79+
80+
include(CMakePackageConfigHelpers)
81+
include(GNUInstallDirs)
82+
83+
set(concurrencpp_directory "concurrencpp-${PROJECT_VERSION}")
84+
set(concurrencpp_include_directory "${CMAKE_INSTALL_INCLUDEDIR}/${concurrencpp_directory}")
85+
86+
install(TARGETS concurrencpp
87+
EXPORT concurrencppTargets
88+
ARCHIVE #
89+
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
90+
COMPONENT concurrencpp_Development
91+
INCLUDES #
92+
DESTINATION "${concurrencpp_include_directory}")
93+
94+
set(concurrencpp_install_cmakedir
95+
"${CMAKE_INSTALL_LIBDIR}/cmake/${concurrencpp_directory}")
96+
97+
write_basic_package_version_file(
98+
concurrencppConfigVersion.cmake
99+
VERSION ${PROJECT_VERSION}
100+
COMPATIBILITY SameMinorVersion
101+
ARCH_INDEPENDENT)
102+
103+
install(EXPORT concurrencppTargets
104+
NAMESPACE concurrencpp::
105+
DESTINATION "${concurrencpp_install_cmakedir}")
106+
107+
install(FILES
108+
"${PROJECT_SOURCE_DIR}/cmake/concurrencppConfig.cmake"
109+
"${PROJECT_BINARY_DIR}/concurrencppConfigVersion.cmake"
110+
DESTINATION "${concurrencpp_install_cmakedir}")
111+
112+
install(DIRECTORY "${PROJECT_SOURCE_DIR}/include/"
113+
DESTINATION "${concurrencpp_include_directory}")

0 commit comments

Comments
 (0)