Skip to content
This repository was archived by the owner on Apr 3, 2025. It is now read-only.

Commit cb69ef1

Browse files
authored
Merge pull request #5 from Tastyep/develop
Develop
2 parents ffd7dd6 + 8795faa commit cb69ef1

37 files changed

Lines changed: 869 additions & 159 deletions

.clang-tidy

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
---
2+
Checks: '*,-cert-err58-cpp,-clang-analyzer-alpha*,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-member-init,-cppcoreguidelines-pro-type-reinterpret-cast,-cppcoreguidelines-pro-type-union-access,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-pro-type-static-cast-downcast,-cppcoreguidelines-special-member-functions,- cppcoreguidelines-no-malloc ,-google-readability-todo,-google-runtime-references,-hicpp-member-init,-hicpp-special-member-functions,-hicpp-no-assembler,-llvm-include-order,-llvm-namespace-comment,-llvm-header-guard,-modernize-use-using,-modernize-pass-by-value,-performance-unnecessary-value-param,-readability-identifier-naming,-readability-named-parameter,-readability-implicit-bool-cast,-readability-redundant-declaration,-readability-simplify-boolean-expr'
3+
WarningsAsErrors: '*'
4+
HeaderFilterRegex: ''
5+
AnalyzeTemporaryDtors: false
6+
FormatStyle: none
7+
CheckOptions:
8+
- key: cert-dcl59-cpp.HeaderFileExtensions
9+
value: h,hh,hpp,hxx
10+
- key: cert-err09-cpp.CheckThrowTemporaries
11+
value: '1'
12+
- key: cert-err61-cpp.CheckThrowTemporaries
13+
value: '1'
14+
- key: cert-oop11-cpp.IncludeStyle
15+
value: llvm
16+
- key: google-build-namespaces.HeaderFileExtensions
17+
value: h,hh,hpp,hxx
18+
- key: google-global-names-in-headers.HeaderFileExtensions
19+
value: h
20+
- key: google-readability-braces-around-statements.ShortStatementLines
21+
value: '1'
22+
- key: google-readability-function-size.BranchThreshold
23+
value: '4294967295'
24+
- key: google-readability-function-size.LineThreshold
25+
value: '4294967295'
26+
- key: google-readability-function-size.NestingThreshold
27+
value: '4294967295'
28+
- key: google-readability-function-size.ParameterThreshold
29+
value: '4294967295'
30+
- key: google-readability-function-size.StatementThreshold
31+
value: '800'
32+
- key: google-readability-namespace-comments.ShortNamespaceLines
33+
value: '10'
34+
- key: google-readability-namespace-comments.SpacesBeforeComments
35+
value: '2'
36+
- key: google-runtime-int.SignedTypePrefix
37+
value: int
38+
- key: google-runtime-int.TypeSuffix
39+
value: _t
40+
- key: google-runtime-int.UnsignedTypePrefix
41+
value: uint
42+
- key: hicpp-function-size.BranchThreshold
43+
value: '4294967295'
44+
- key: hicpp-function-size.LineThreshold
45+
value: '4294967295'
46+
- key: hicpp-function-size.NestingThreshold
47+
value: '4294967295'
48+
- key: hicpp-function-size.ParameterThreshold
49+
value: '4294967295'
50+
- key: hicpp-function-size.StatementThreshold
51+
value: '800'
52+
- key: hicpp-named-parameter.IgnoreFailedSplit
53+
value: '0'
54+
- key: misc-argument-comment.StrictMode
55+
value: '0'
56+
- key: misc-assert-side-effect.AssertMacros
57+
value: assert
58+
- key: misc-assert-side-effect.CheckFunctionCalls
59+
value: '0'
60+
- key: misc-dangling-handle.HandleClasses
61+
value: 'std::basic_string_view;std::experimental::basic_string_view'
62+
- key: misc-definitions-in-headers.HeaderFileExtensions
63+
value: ',h,hh,hpp,hxx'
64+
- key: misc-definitions-in-headers.UseHeaderFileExtension
65+
value: '1'
66+
- key: misc-misplaced-widening-cast.CheckImplicitCasts
67+
value: '0'
68+
- key: misc-move-constructor-init.IncludeStyle
69+
value: llvm
70+
- key: misc-sizeof-expression.WarnOnSizeOfCompareToConstant
71+
value: '1'
72+
- key: misc-sizeof-expression.WarnOnSizeOfConstant
73+
value: '1'
74+
- key: misc-sizeof-expression.WarnOnSizeOfThis
75+
value: '1'
76+
- key: misc-string-constructor.LargeLengthThreshold
77+
value: '8388608'
78+
- key: misc-string-constructor.WarnOnLargeLength
79+
value: '1'
80+
- key: misc-suspicious-enum-usage.StrictMode
81+
value: '0'
82+
- key: misc-suspicious-missing-comma.MaxConcatenatedTokens
83+
value: '5'
84+
- key: misc-suspicious-missing-comma.RatioThreshold
85+
value: '0.200000'
86+
- key: misc-suspicious-missing-comma.SizeThreshold
87+
value: '5'
88+
- key: misc-suspicious-string-compare.StringCompareLikeFunctions
89+
value: ''
90+
- key: misc-suspicious-string-compare.WarnOnImplicitComparison
91+
value: '1'
92+
- key: misc-suspicious-string-compare.WarnOnLogicalNotComparison
93+
value: '0'
94+
- key: misc-throw-by-value-catch-by-reference.CheckThrowTemporaries
95+
value: '1'
96+
- key: modernize-loop-convert.MaxCopySize
97+
value: '16'
98+
- key: modernize-loop-convert.MinConfidence
99+
value: reasonable
100+
- key: modernize-loop-convert.NamingStyle
101+
value: CamelCase
102+
- key: modernize-make-shared.IncludeStyle
103+
value: '1'
104+
- key: modernize-make-shared.MakeSmartPtrFunction
105+
value: 'std::make_shared'
106+
- key: modernize-make-shared.MakeSmartPtrFunctionHeader
107+
value: memory
108+
- key: modernize-make-unique.IncludeStyle
109+
value: '1'
110+
- key: modernize-make-unique.MakeSmartPtrFunction
111+
value: 'std::make_unique'
112+
- key: modernize-make-unique.MakeSmartPtrFunctionHeader
113+
value: memory
114+
- key: modernize-pass-by-value.IncludeStyle
115+
value: llvm
116+
- key: modernize-raw-string-literal.ReplaceShorterLiterals
117+
value: '0'
118+
- key: modernize-replace-auto-ptr.IncludeStyle
119+
value: llvm
120+
- key: modernize-replace-random-shuffle.IncludeStyle
121+
value: llvm
122+
- key: modernize-use-auto.RemoveStars
123+
value: '0'
124+
- key: modernize-use-default-member-init.IgnoreMacros
125+
value: '1'
126+
- key: modernize-use-default-member-init.UseAssignment
127+
value: '0'
128+
- key: modernize-use-emplace.ContainersWithPushBack
129+
value: '::std::vector;::std::list;::std::deque'
130+
- key: modernize-use-emplace.SmartPointers
131+
value: '::std::shared_ptr;::std::unique_ptr;::std::auto_ptr;::std::weak_ptr'
132+
- key: modernize-use-emplace.TupleMakeFunctions
133+
value: '::std::make_pair;::std::make_tuple'
134+
- key: modernize-use-emplace.TupleTypes
135+
value: '::std::pair;::std::tuple'
136+
- key: modernize-use-noexcept.ReplacementString
137+
value: ''
138+
- key: modernize-use-noexcept.UseNoexceptFalse
139+
value: '1'
140+
- key: modernize-use-nullptr.NullMacros
141+
value: 'NULL'
142+
- key: modernize-use-transparent-functors.SafeMode
143+
value: '0'
144+
- key: performance-faster-string-find.StringLikeClasses
145+
value: 'std::basic_string'
146+
- key: performance-for-range-copy.WarnOnAllAutoCopies
147+
value: '0'
148+
- key: performance-inefficient-string-concatenation.StrictMode
149+
value: '0'
150+
- key: performance-inefficient-vector-operation.VectorLikeClasses
151+
value: '::std::vector'
152+
- key: performance-type-promotion-in-math-fn.IncludeStyle
153+
value: llvm
154+
- key: readability-braces-around-statements.ShortStatementLines
155+
value: '0'
156+
- key: readability-function-size.BranchThreshold
157+
value: '4294967295'
158+
- key: readability-function-size.LineThreshold
159+
value: '4294967295'
160+
- key: readability-function-size.NestingThreshold
161+
value: '4294967295'
162+
- key: readability-function-size.ParameterThreshold
163+
value: '4294967295'
164+
- key: readability-function-size.StatementThreshold
165+
value: '800'
166+
...

.travis.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# This file configures the build and run environment on https://travis-ci.org/
2+
3+
# Specify the operating systems on which to test for.
4+
os:
5+
- linux
6+
7+
# For details on building a C++ project see: https://docs.travis-ci.com/user/languages/cpp/
8+
sudo: required
9+
dist: trusty
10+
language: cpp
11+
12+
matrix:
13+
include:
14+
- compiler: gcc
15+
addons:
16+
apt:
17+
sources:
18+
- ubuntu-toolchain-r-test
19+
packages:
20+
- g++-6
21+
env:
22+
- COMPILER=g++-6 C_COMPILER=gcc-6 STEP=gcc
23+
- compiler: clang
24+
addons:
25+
apt:
26+
sources:
27+
- llvm-toolchain-trusty-6.0
28+
- ubuntu-toolchain-r-test
29+
packages:
30+
- clang-6.0
31+
env:
32+
- COMPILER=clang++-6.0 C_COMPILER=clang-6.0 STEP=clang
33+
- compiler: clang-tidy
34+
addons:
35+
apt:
36+
sources:
37+
- ubuntu-toolchain-r-test
38+
- llvm-toolchain-trusty-6.0
39+
packages:
40+
- clang-tidy-6.0
41+
- clang-6.0
42+
env:
43+
- COMPILER=clang++-6.0 C_COMPILER=clang-6.0 STEP=clang-tidy
44+
45+
install:
46+
- export "SOURCE_ROOT=${TRAVIS_BUILD_DIR}" "BUILD_ROOT=${TRAVIS_BUILD_DIR}/build"
47+
- export "CXX=$COMPILER";
48+
49+
before_script:
50+
- mkdir -p ${BUILD_ROOT} && cd ${BUILD_ROOT}
51+
52+
script:
53+
- if [[ "$STEP" == "clang" ]]; then
54+
(../configure.sh -c -t && make -j8 && ./TaskManager-tester);
55+
fi
56+
- if [[ "$STEP" == "gcc" ]]; then
57+
(../configure.sh -t && make -j8 && ./TaskManager-tester);
58+
fi
59+
- if [[ "$STEP" == "clang-tidy" ]]; then
60+
(../configure.sh -c -y && make -j8 && make clang-tidy);
61+
fi

CMakeLists.txt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ set(MODULE_DIR cmake)
99
set(SOURCE_DIR src)
1010
set(INCLUDE_DIR include)
1111
set(LIB_DIR lib)
12+
set(LIB_INCLUDE_DIR "${INCLUDE_DIR}/${PROJECT_NAME}")
1213
set(TEST_DIR test)
1314
set(IMPLEMENTATION_DIR detail)
1415
set(TESTER_NAME "${PROJECT_NAME}-tester")
@@ -41,21 +42,26 @@ include(Sources)
4142
include_directories (${PROJECT_SOURCE_DIR})
4243
include_directories (${PROJECT_SOURCE_DIR}/${INCLUDE_DIR})
4344

45+
# Add required unix libraries
4446
add_library(${LIB_NAME} STATIC ${LIB_SOURCE_FILES})
4547

48+
if(TASK_MANAGER_BUILD_TESTS)
49+
include(EnableTests)
50+
endif()
51+
4652
if(TASK_MANAGER_ENABLE_CLANGTIDY AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
4753
include(EnableClangTidy)
48-
enable_clangtidy(SOURCES "${LIB_SOURCE_FILES}")
54+
enable_clangtidy(SOURCES "${PROJECT_SOURCE_DIR}/${SOURCE_DIR}")
4955
endif()
5056

51-
if(TASK_MANAGER_BUILD_TESTS)
52-
include(EnableTests)
57+
if(TASK_MANAGER_ENABLE_COVERAGE)
58+
include(EnableTestCoverage)
59+
add_coverage_flags(TARGETS ${BIN_NAME} ${LIB_NAME})
5360
endif()
5461

5562

5663
install(TARGETS ${LIB_NAME} DESTINATION ${LIB_DIR})
57-
install(FILES ${LIB_EXPOSED_HEADER_FILES} DESTINATION "${INCLUDE_DIR}/${PROJECT_NAME}")
58-
install(DIRECTORY ${LIB_REQUIRED_DIRS} DESTINATION "${INCLUDE_DIR}/${PROJECT_NAME}")
64+
install(DIRECTORY ${LIB_INCLUDE_DIR} DESTINATION ${INCLUDE_DIR})
5965

6066
set(TASK_MANAGER_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/${INCLUDE_DIR})
6167
set(TASK_MANAGER_INCLUDE_DIRS ${TASK_MANAGER_INCLUDE_DIR} )

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
![alt text](https://raw.githubusercontent.com/Tastyep/TaskManager/master/assets/task_manager_logo.png)
22

3+
[![Build Status](https://travis-ci.org/Tastyep/TaskManager.svg?branch=master)](https://travis-ci.org/Tastyep/TaskManager)
4+
35
TaskManager is an asynchronous task management library using the features of C++14.
46

57
### Requirements
@@ -16,6 +18,9 @@ A compiler supporting the C++14 features.
1618

1719
### Basic Usage
1820
###### Manager
21+
22+
Note: The following examples use chrono literals.
23+
1924
```C++
2025
// Create the thread pool with the initial number of threads (2 here).
2126
Task::Module::init(2);
@@ -24,7 +29,7 @@ Task::Module::init(2);
2429
auto manager = Task::Module::makeManager(1);
2530

2631
// Add a new task and get its future.
27-
auto future = manager.launch([] { return 42; });
32+
auto future = manager.push([] { return 42; });
2833

2934
// Get the result from the future and print it.
3035
std::cout << future.get() << std::endl; // Prints 42
@@ -47,8 +52,8 @@ auto scheduler = Task::Module::makeScheduler(1);
4752
size_t n = 0;
4853
4954
// Add new tasks and get the future.
50-
auto future = scheduler.scheduleIn("Task1", std::chrono::seconds(2), [&n] { n++; });
51-
scheduler.scheduleIn("Task2", std::chrono::seconds(1), [&n] { n = 41 });
55+
auto future = scheduler.scheduleIn("Task1", 2s, [&n] { n++; });
56+
scheduler.scheduleIn("Task2", 1s, [&n] { n = 41 });
5257
5358
// Get the future and print the updated value.
5459
future.get()

assets/task_manager_logo.png

-259 Bytes
Loading

cmake/CleanCoverage.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Enable CMP0009 new behaviour
2+
cmake_minimum_required(VERSION 2.6.2 FATAL_ERROR)
3+
4+
# Remove old gcda files
5+
file(GLOB_RECURSE GCDA_FILES "${PROJECT_BINARY_DIR}/*.gcda")
6+
if(NOT GCDA_FILES STREQUAL "")
7+
file(REMOVE ${GCDA_FILES})
8+
endif()

cmake/CompilerFlags.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ include(CheckCompilerFlags)
33
# Check and define C compiler flags
44
check_cxx_compiler_flags(
55
FLAGS
6-
"-std=c++1y"
6+
"-std=c++14"
77
"-Wall" "-pedantic" "-Wextra"
88
"-Wcast-align"
99
"-Wcast-qual" "-Wconversion"

0 commit comments

Comments
 (0)