Skip to content

Commit 43b6c7d

Browse files
committed
Revert "refactor: remove async++"
This reverts commit 7cbaa85.
1 parent b405d67 commit 43b6c7d

31 files changed

+4939
-0
lines changed

3rdparty/3rdparty.pri

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
include($$PWD/asyncplusplus.pri)
12
include($$PWD/qtpromise/qtpromise.pri)
23
include($$PWD/qcustomplot/qcustomplot.pri)
34
include($$PWD/qtcsv/qtcsv.pri)

3rdparty/asyncplusplus.pri

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
INCLUDEPATH += $$PWD/asyncplusplus/include
3+
4+
HEADERS += \
5+
$$PWD/asyncplusplus/include/async++.h \
6+
$$PWD/asyncplusplus/src/fifo_queue.h \
7+
$$PWD/asyncplusplus/src/internal.h \
8+
$$PWD/asyncplusplus/src/singleton.h \
9+
$$PWD/asyncplusplus/src/task_wait_event.h \
10+
$$PWD/asyncplusplus/src/work_steal_queue.h
11+
12+
SOURCES += \
13+
$$PWD/asyncplusplus/src/scheduler.cpp \
14+
$$PWD/asyncplusplus/src/threadpool_scheduler.cpp

3rdparty/asyncplusplus/.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Compiled Object files
2+
*.slo
3+
*.lo
4+
*.o
5+
6+
# Compiled Dynamic libraries
7+
*.so
8+
*.dylib
9+
10+
# Compiled Static libraries
11+
*.lai
12+
*.la
13+
*.a
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
include(CMakeFindDependencyMacro)
2+
find_dependency(Threads)
3+
include("${CMAKE_CURRENT_LIST_DIR}/Async++.cmake")
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
# Copyright (c) 2015 Amanieu d'Antras
2+
#
3+
# Permission is hereby granted, free of charge, to any person obtaining a copy
4+
# of this software and associated documentation files (the "Software"), to deal
5+
# in the Software without restriction, including without limitation the rights
6+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
# copies of the Software, and to permit persons to whom the Software is
8+
# furnished to do so, subject to the following conditions:
9+
#
10+
# The above copyright notice and this permission notice shall be included in
11+
# all copies or substantial portions of the Software.
12+
#
13+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
# THE SOFTWARE.
20+
21+
cmake_minimum_required(VERSION 3.1)
22+
project(Async++ C CXX)
23+
24+
option(BUILD_SHARED_LIBS "Build Async++ as a shared library" ON)
25+
option(USE_CXX_EXCEPTIONS "Enable C++ exception support" ON)
26+
if (APPLE)
27+
option(BUILD_FRAMEWORK "Build a Mac OS X framework instead of a library" OFF)
28+
if (BUILD_FRAMEWORK AND NOT BUILD_SHARED_LIBS)
29+
message(FATAL_ERROR "Can't build a framework with static libraries")
30+
endif()
31+
endif()
32+
33+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
34+
35+
# Add all source and header files so IDEs can see them
36+
set(ASYNCXX_INCLUDE
37+
${PROJECT_SOURCE_DIR}/include/async++/aligned_alloc.h
38+
${PROJECT_SOURCE_DIR}/include/async++/cancel.h
39+
${PROJECT_SOURCE_DIR}/include/async++/continuation_vector.h
40+
${PROJECT_SOURCE_DIR}/include/async++/parallel_for.h
41+
${PROJECT_SOURCE_DIR}/include/async++/parallel_invoke.h
42+
${PROJECT_SOURCE_DIR}/include/async++/parallel_reduce.h
43+
${PROJECT_SOURCE_DIR}/include/async++/partitioner.h
44+
${PROJECT_SOURCE_DIR}/include/async++/range.h
45+
${PROJECT_SOURCE_DIR}/include/async++/ref_count.h
46+
${PROJECT_SOURCE_DIR}/include/async++/scheduler.h
47+
${PROJECT_SOURCE_DIR}/include/async++/scheduler_fwd.h
48+
${PROJECT_SOURCE_DIR}/include/async++/task.h
49+
${PROJECT_SOURCE_DIR}/include/async++/task_base.h
50+
${PROJECT_SOURCE_DIR}/include/async++/traits.h
51+
${PROJECT_SOURCE_DIR}/include/async++/when_all_any.h
52+
)
53+
set(ASYNCXX_SRC
54+
${PROJECT_SOURCE_DIR}/src/internal.h
55+
${PROJECT_SOURCE_DIR}/src/fifo_queue.h
56+
${PROJECT_SOURCE_DIR}/src/scheduler.cpp
57+
${PROJECT_SOURCE_DIR}/src/singleton.h
58+
${PROJECT_SOURCE_DIR}/src/task_wait_event.h
59+
${PROJECT_SOURCE_DIR}/src/threadpool_scheduler.cpp
60+
${PROJECT_SOURCE_DIR}/src/work_steal_queue.h
61+
)
62+
source_group(include FILES ${PROJECT_SOURCE_DIR}/include/async++.h ${ASYNCXX_INCLUDE})
63+
source_group(src FILES ${ASYNCXX_SRC})
64+
add_library(Async++ ${PROJECT_SOURCE_DIR}/include/async++.h ${ASYNCXX_INCLUDE} ${ASYNCXX_SRC})
65+
66+
# Async++ only depends on the C++11 standard libraries, but some implementations
67+
# require the -pthread compiler flag to enable threading functionality.
68+
if (NOT MSVC)
69+
target_compile_options(Async++ PRIVATE -std=c++11)
70+
endif()
71+
if (APPLE)
72+
# Use libc++ on Mac because the shipped libstdc++ version is ancient
73+
target_compile_options(Async++ PRIVATE -stdlib=libc++)
74+
set_target_properties(Async++ PROPERTIES LINK_FLAGS -stdlib=libc++)
75+
endif()
76+
set(THREADS_PREFER_PTHREAD_FLAG ON)
77+
find_package(Threads REQUIRED)
78+
target_link_libraries(Async++ PUBLIC Threads::Threads)
79+
80+
# Set up preprocessor definitions
81+
target_include_directories(Async++ PRIVATE ${PROJECT_SOURCE_DIR}/include)
82+
set_target_properties(Async++ PROPERTIES DEFINE_SYMBOL LIBASYNC_BUILD)
83+
if (BUILD_SHARED_LIBS)
84+
# Minimize the set of symbols exported by libraries
85+
set_target_properties(Async++ PROPERTIES CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN ON)
86+
else()
87+
target_compile_definitions(Async++ PUBLIC LIBASYNC_STATIC)
88+
endif()
89+
90+
# Enable warnings for strict C++ standard conformance
91+
if (NOT MSVC)
92+
target_compile_options(Async++ PRIVATE -Wall -Wextra -pedantic)
93+
endif()
94+
95+
# Async++ doesn't make use of RTTI information, so don't generate it.
96+
# There are issues on Apple platforms with exceptions and -fno-rtti, so keep it
97+
# enabled there.
98+
# See https://stackoverflow.com/questions/21737201/problems-throwing-and-catching-exceptions-on-os-x-with-fno-rtti
99+
if (MSVC)
100+
target_compile_options(Async++ PRIVATE /GR-)
101+
elseif(NOT APPLE)
102+
target_compile_options(Async++ PRIVATE -fno-rtti)
103+
endif()
104+
105+
# Allow disabling exceptions, but warn the user about the consequences
106+
if (NOT USE_CXX_EXCEPTIONS)
107+
message(WARNING "Exceptions have been disabled. Any operation that would "
108+
"throw an exception will result in a call to std::abort() instead.")
109+
target_compile_definitions(Async++ PUBLIC LIBASYNC_NO_EXCEPTIONS)
110+
if (MSVC)
111+
target_compile_options(Async++ PUBLIC /EHs-c-)
112+
else()
113+
target_compile_options(Async++ PUBLIC -fno-exceptions)
114+
endif()
115+
endif()
116+
117+
include(CMakePackageConfigHelpers)
118+
configure_package_config_file("${CMAKE_CURRENT_LIST_DIR}/Async++Config.cmake.in"
119+
"${PROJECT_BINARY_DIR}/Async++Config.cmake"
120+
INSTALL_DESTINATION cmake
121+
)
122+
123+
install(FILES "${PROJECT_BINARY_DIR}/Async++Config.cmake"
124+
DESTINATION cmake
125+
)
126+
127+
# Install the library and produce a CMake export script
128+
include(GNUInstallDirs)
129+
install(TARGETS Async++
130+
EXPORT Async++
131+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
132+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
133+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
134+
FRAMEWORK DESTINATION Frameworks
135+
)
136+
export(EXPORT Async++)
137+
install(EXPORT Async++ DESTINATION cmake)
138+
if (APPLE AND BUILD_FRAMEWORK)
139+
set_target_properties(Async++ PROPERTIES OUTPUT_NAME Async++ FRAMEWORK ON)
140+
set_source_files_properties(${ASYNCXX_INCLUDE} PROPERTIES MACOSX_PACKAGE_LOCATION Headers/async++)
141+
set_source_files_properties(${PROJECT_SOURCE_DIR}/include/async++.h PROPERTIES MACOSX_PACKAGE_LOCATION Headers)
142+
else()
143+
set_target_properties(Async++ PROPERTIES OUTPUT_NAME async++)
144+
target_include_directories(Async++ INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>)
145+
install(FILES ${PROJECT_SOURCE_DIR}/include/async++.h DESTINATION include)
146+
install(FILES ${ASYNCXX_INCLUDE} DESTINATION include/async++)
147+
endif()
148+
149+
SET(CPACK_GENERATOR "DEB")
150+
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "none") #required
151+
152+
INCLUDE(CPack)

3rdparty/asyncplusplus/LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2015 Amanieu d'Antras
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

3rdparty/asyncplusplus/README.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
Async++
2+
=======
3+
4+
Async++ is a lightweight concurrency framework for C++11. The concept was inspired by the [Microsoft PPL library](http://msdn.microsoft.com/en-us/library/dd492418.aspx) and the [N3428](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3428.pdf) C++ standard proposal.
5+
6+
Example
7+
-------
8+
Here is a short example which shows some features of Async++:
9+
10+
```c++
11+
#include <iostream>
12+
#include <async++.h>
13+
14+
int main()
15+
{
16+
auto task1 = async::spawn([] {
17+
std::cout << "Task 1 executes asynchronously" << std::endl;
18+
});
19+
auto task2 = async::spawn([]() -> int {
20+
std::cout << "Task 2 executes in parallel with task 1" << std::endl;
21+
return 42;
22+
});
23+
auto task3 = task2.then([](int value) -> int {
24+
std::cout << "Task 3 executes after task 2, which returned "
25+
<< value << std::endl;
26+
return value * 3;
27+
});
28+
auto task4 = async::when_all(task1, task3);
29+
auto task5 = task4.then([](std::tuple<async::task<void>,
30+
async::task<int>> results) {
31+
std::cout << "Task 5 executes after tasks 1 and 3. Task 3 returned "
32+
<< std::get<1>(results).get() << std::endl;
33+
});
34+
35+
task5.get();
36+
std::cout << "Task 5 has completed" << std::endl;
37+
38+
async::parallel_invoke([] {
39+
std::cout << "This is executed in parallel..." << std::endl;
40+
}, [] {
41+
std::cout << "with this" << std::endl;
42+
});
43+
44+
async::parallel_for(async::irange(0, 5), [](int x) {
45+
std::cout << x;
46+
});
47+
std::cout << std::endl;
48+
49+
int r = async::parallel_reduce({1, 2, 3, 4}, 0, [](int x, int y) {
50+
return x + y;
51+
});
52+
std::cout << "The sum of {1, 2, 3, 4} is " << r << std::endl;
53+
}
54+
55+
// Output (order may vary in some places):
56+
// Task 1 executes asynchronously
57+
// Task 2 executes in parallel with task 1
58+
// Task 3 executes after task 2, which returned 42
59+
// Task 5 executes after tasks 1 and 3. Task 3 returned 126
60+
// Task 5 has completed
61+
// This is executed in parallel...
62+
// with this
63+
// 01234
64+
// The sum of {1, 2, 3, 4} is 10
65+
```
66+
67+
Supported Platforms
68+
-------------------
69+
70+
The only requirement to use Async++ is a C++11 compiler and standard library. Unfortunately C++11 is not yet fully implemented on most platforms. Here is the list of OS and compiler combinations which are known to work.
71+
72+
- Linux: Works with GCC 4.7+, Clang 3.2+ and Intel compiler 15+.
73+
- Mac: Works with Apple Clang (using libc++). GCC also works but you must get a recent version (4.7+).
74+
- iOS: Works with Apple Clang (using libc++). Note: because iOS has no thread local support, the library uses a workaround based on pthreads.
75+
- Windows: Works with GCC 4.8+ (with pthread-win32) and Visual Studio 2013+.
76+
77+
Building and Installing
78+
-----------------------
79+
Instructions for compiling Async++ and using it in your code are available on the [Building and Installing](https://github.com/Amanieu/asyncplusplus/wiki/Building-and-Installing) page.
80+
81+
Documentation
82+
------------
83+
The Async++ documentation is split into four parts:
84+
- [Tasks](https://github.com/Amanieu/asyncplusplus/wiki/Tasks): This describes task objects which are the core Async++. Reading this first is strongly recommended.
85+
- [Parallel algorithms](https://github.com/Amanieu/asyncplusplus/wiki/Parallel-algorithms): This describes functions to run work on ranges in parallel.
86+
- [Schedulers](https://github.com/Amanieu/asyncplusplus/wiki/Schedulers): This describes the low-level details of Async++ and how to customize it.
87+
- [API Reference](https://github.com/Amanieu/asyncplusplus/wiki/API-Reference): This gives detailed descriptions of all the classes and functions available in Async++.
88+
89+
Contact
90+
-------
91+
You can contact me by email at [email protected].

0 commit comments

Comments
 (0)