Skip to content

Commit

Permalink
Adding pre_exit() to resolve #409 (#493)
Browse files Browse the repository at this point in the history
* pre_exit

Added pre_exit handler to shut down the default executors before the program exits to avoid detached and canceled tasks from running concurrently with  at_exit handlers and global destructors.

* Adding pre_exit() to serial queue test

* Updating Docker image

- Updating docker file and instructions to build docks.
- Removed old BBEdit project

* In progress - working on updating docker based hyde update

Only committing so I can merge and continue work.

* Checkpoint before trying to build docs.

* Committing safe changes.

* Adding pre-exit docs

* Using global fixture for `pre_exit()` invocation

Switched to using a global fixture for pre_exit invocation.
Started filling in release notes.

* Attempt to fix incorrectly configured boost for wasm build.

* Trivial conversion of serial_queue_test to use boost test

I did a trivial conversion of serial_queue_test to use boost test to fix a link error. All the tests need to be systematically revisited.
  • Loading branch information
sean-parent authored Sep 3, 2022
1 parent 85df183 commit e69d4bf
Show file tree
Hide file tree
Showing 35 changed files with 652 additions and 5,914 deletions.
45 changes: 29 additions & 16 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## v.1.7.0 - 2022 - September 2
- Breaking Changes
- The build setup now requires executing CMake to generate a config.hpp file for the build. This was done to avoid ODR/API/ABI breakage from having the library self-configure differently when used by multiple sub-projects. See the [build instructions](https://github.com/stlab/libraries/runs/7903922028?check_suite_focus=true).
- To avoid having canceled or detached tasks execute concurrently with exit, leading to undefined behavior, a [`pre_exit()`](https://stlab.cc/libraries/pre_exit.hpp) call was added which must be invoked if using the [`default_executor`](https://stlab.cc/libraries/concurrency/default_executor.hpp/) prior to returning from `main()` or invoking `exit()`. If `quick_exit()` is used, `pre_exit()` is not necessary.
- Changes & Additions
- The documentation source has been moved from `stlab/stlab.github.io` into `stlab/libraries/docs`. The documentation was re-generated with the latest version of [hyde](https://github.com/adobe/hyde) but still requires some manual fixup. We are working with the hyde team to address this.
- `blocking_get()` and associated functions have been renamed [`await()`](https://stlab.cc/libraries/concurrency/await.hpp/) and the corresponding `blocking_get()` API is deprecated.
- Fixed issues
- [#408](https://github.com/stlab/libraries/issues/408) The prior version of the portable `blocking_get()` would steal tasks while blocking. This can lead to deadlocks if the task stolen is the one being waited on. The portable default executor now behaves more like the platform default executors and will add additional threads (to a limit) to the thread pool if there are no available threads and `await()` is used.
- [#406](https://github.com/stlab/libraries/issues/406) Added support for a `main_exector` for WASM when compiled with threads enabled.
- [#405](https://github.com/stlab/libraries/issues/405) Added official WASM support and WASM builds are now part of our CI.
- A number of bugs were fixed with `future<>::recover()` when used with move-only types.

## v.1.6.2 - 2021 - March 25
- Fixed issues
- [#371]:(https://github.com/stlab/libraries/issues/371)Missing include in concurrency/utility.hpp
Expand Down Expand Up @@ -36,17 +49,17 @@
- [#317](https://github.com/stlab/libraries/issues/346): Recovery continuations not invoked on broken promises
- Better conan.io support (Many thanks to Fernando Pelliccioni)
- Fix several minor scripting and configuration issues (Many thanks to Fernando Pelliccioni)
- Fix in SerialQueue UnitTest that could lead to dead lock on systems with few cores
- Fix in SerialQueue UnitTest that could lead to dead lock on systems with few cores
## v1.5.3 - 2020 - September 16
- Fixed issues
- [#312](https://github.com/stlab/libraries/issues/312): default_executor implementation for Windows has a memory leak
- [#305](https://github.com/stlab/libraries/issues/305) stlab/concurrency/future.hpp won't compile with C++20
- [#303](https://github.com/stlab/libraries/issues/) range based stlab::when_any data race
- Enhancement
- Adding Forest container and algorithms
- Adding Forest container and algorithms
## v1.5.2 - 2020 - February 05
- Fixed issues
- [#292](https://github.com/stlab/libraries/issues/292): What happened to our mutable lambdas?
Expand All @@ -63,18 +76,18 @@
- [#260](https://github.com/stlab/libraries/issues/260): set_exception() should be a const member.
- [#248](https://github.com/stlab/libraries/issues/248): Lifetime of receivers returned by operator|
- [#243](https://github.com/stlab/libraries/issues/243): Vector of move only type passed to continuation fails to compile.
- Enhancements
- [#269](https://github.com/stlab/libraries/issues/269): Extend the default_executor with high and low priority
- [#262](https://github.com/stlab/libraries/issues/262): `system_timer` interface is cumbersome. Now it accepts a
- [#262](https://github.com/stlab/libraries/issues/262): `system_timer` interface is cumbersome. Now it accepts a
duration from now. The previously available interface with a time_point is marked as deprecated and will be removed in a future release.
## v1.4.1 - 2019 - February - 08
- Fixed Issues
- [#234](https://github.com/stlab/libraries/issues/234): version is incorrect in stlabConfig.cmake
- [#229](https://github.com/stlab/libraries/issues/229): SIGBUS in future destructor
- [#220](https://github.com/stlab/libraries/issues/220): make_ready_future for move-only types
## v1.4.0 - 2018 - December - 12
- Fixed Issues
- [#208](https://github.com/stlab/libraries/issues/208): g++8.2.0 compiling error
Expand All @@ -96,29 +109,29 @@
## v1.3.3 - 2018 - October - 25
- Fixed Issues
- Fixed Issues
- [#154](https://github.com/stlab/libraries/issues/154) : Compilation error with gcc
- Race condition in timed blocking_get
- Enhancements
- The library can now be included as cmake dependency (Many thanks to Austin McCartney)
- The library can now be included as cmake dependency (Many thanks to Austin McCartney)
## v1.3.2 - 2018 - July - 28
- Fixed Issues
- Fixed Issues
- [#169](https://github.com/stlab/libraries/issues/169) : when_all() appears to ignore the passed-in executor
## v1.3.1 - 2018 - July - 21
- Fixed Issues
- Fixed Issues
- [#169](https://github.com/stlab/libraries/issues/169) : when_all() appears to ignore the passed-in executor
- [#168](https://github.com/stlab/libraries/issues/168) : Main Executor requires "widgets" to be dragged into Qt build
- [#167](https://github.com/stlab/libraries/issues/167) : Main Executor has potential segfault
- [#166](https://github.com/stlab/libraries/issues/166) : Multiple task_system and system_timer are being created
## v1.3.0 - 2018 - July - 15
- Fixed Issues
- Fixed Issues
- [#160](https://github.com/stlab/libraries/issues/160) : main_executor for lib dispatch: `operator()` missing const qualifier
- [#156](https://github.com/stlab/libraries/issues/156) : `set_error()` does not get called
- [#134](https://github.com/stlab/libraries/issues/134) : Using `future<>::detach()` is a possible memory leak
Expand All @@ -130,7 +143,7 @@
## v1.2.0 - 15 June 2018
- Fixed Issues
- Fixed Issues
- [#146](https://github.com/stlab/libraries/issues/146) : when_all() does not compile with move-only objects
- [#142](https://github.com/stlab/libraries/issues/142) : boost/variant.hpp: No such file or directory
- [#119](https://github.com/stlab/libraries/issues/119) : blocking_get randomly does not return
Expand All @@ -139,7 +152,7 @@
- Adding usage of std::optional, std::variant or std::experimental::optional when compiling with C++17 mode. So the dependency to boost.optional is optional.
- Adding co-routine support for futures. (Only for VS 2017 and clang 5.0)
- Adding main_executor for Qt support
## v1.1.1 - 13 December 2017
- Fixed Issues
Expand Down Expand Up @@ -175,7 +188,7 @@ this is restricted to copyable types `T`.
- Extended Travis CI support
- AppVeyor support
- Breaking Changes
- With [Issue #85](https://github.com/stlab/libraries/issues/85) the interface of `make_ready_future` and
- With [Issue #85](https://github.com/stlab/libraries/issues/85) the interface of `make_ready_future` and
`make_exceptional_future` now require an executor as a second parameter.
## v1.0 - 10 June 2017
Expand Down
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,10 @@ if ( BUILD_TESTING )
# preprocessor definition when the unit test compiled resources are
# provided by a shared library rather than a static library.
#
target_compile_definitions( testing INTERFACE
$<$<NOT:$<BOOL:${Boost_USE_STATIC_LIBS}>>:BOOST_TEST_DYN_LINK>)

if (NOT Boost_USE_STATIC_LIBS)
target_compile_definitions( testing INTERFACE BOOST_TEST_DYN_LINK=1)
endif()

add_subdirectory( test )
endif()
Expand Down
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ A typical invocation might look like this:
cmake -S . -B ../BUILD -GNinja -DCMAKE_CXX_STANDARD=17 -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF
```

If you organize the build directory into subdirectories you can support multiple configurations.

```
cmake -S . -B ../builds/portable -GXcode -DCMAKE_CXX_STANDARD=17 -DBUILD_TESTING=ON -DSTLAB_TASK_SYSTEM=portable
```

### Build

If your configuration command was successful, go to your build directory (`cd ../BUILD`) and invoke:
Expand All @@ -92,7 +98,7 @@ cmake --build .

## Testing

Running the tests in the `BUILD` directory is as simple as invoking
Running the tests in the `BUILD` directory is as simple as invoking

```
ctest -C Debug
Expand All @@ -111,6 +117,13 @@ STLab uses [hyde](https://github.com/adobe/hyde) to generate documentation boile
When adding a new public API, you should invoke

```
docker run --platform linux/x86_64 --mount type=bind,source="$(pwd)/..",target=/mnt/host \
--tty --interactive \
hyde bash
```

```
cd /mnt/host/libraries
./validate_docs.sh --update
```

Expand Down
1 change: 1 addition & 0 deletions docs/.ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.7.4
Loading

0 comments on commit e69d4bf

Please sign in to comment.