Skip to content

Commit 74b7eaf

Browse files
[V4] Cancellation 2.0 (#72)
* sketch * spell * await suspend * in final suspend * todo * root declares what it is * final suspend loop on cancel * restore assert * remove pre-suspend check * owning parent * return adr abstraction * Revert "owning parent" This reverts commit 81fb23b. * extra template param in pkg * op overloads * check return is non null * todo * cancel propagation * PERF: move propagation to await_transform * PERF: move check * Revert "PERF: move check" This reverts commit 37f99b5. * Revert "PERF: move propagation to await_transform" This reverts commit b3ec305. * split final suspend tripple final suspend * Revert "remove pre-suspend check" This reverts commit a2af5da. * Reapply "remove pre-suspend check" This reverts commit 953975b. * drop inline forcing * revert owner split release * unranched * Revert "unranched" This reverts commit c80f7d7. * unique types in pkg * comments * better names * rm comments * full pre-release * full fused release This reverts commit fe90470. * Revert "full fused release" This reverts commit 764b6d8. * double branch reduced * Revert "double branch reduced" This reverts commit 12bb9c5. * fixup negation * fixup todo * refactor names of final suspend parts * set cancellation in await suspend * unconditional cancel test * bad * Revert "bad" This reverts commit fcc1924. * Revert "unconditional cancel test" This reverts commit 20141ee. * rm comment * constify * add todo * add todo * cancel test TMP: cancel branch tests format add joins fuzz more fuzz format tigher structure for agents drop all ref to lints fix conditional * join cancel fix * cancel fuzz * fix conditional * agents tweaks * Revert "cancel fuzz" This reverts commit 7de5615aa73c26cf33f2e064e7501718fb1f1104. * todo * first pass * second pass * touchup inculdes * drop C from bench * no fixed import * all use full imports * tidy up cmakelists * alternative handling of cancel at join * further refine cancel path * tmp * not all threads * don't use internal * complexity * Revert "cancel test" This reverts commit 30db539. * structure for stop.cxx * stop.cxx * use stop.cxx * better op names * todo * cancel tests * root package propagates exception * stop plumbed * fix infinite loop * access the stop source of the reciver * todo * allow early cancellation of root * tmp cancel * co_await scope() * no export stop source * explicitly default initialize * basic cancel test * busy versions * tests * TMP no bind * clean ups * cancel notes * Revert "TMP no bind" This reverts commit 3b9bd7a. * move external to benchmark * stop token * use stop token * split ops * markdown (delete before merge) * fix promise * fix tests * reciever changes * todo * use scoped join * format * rename 1 * rename 2 * rename 3 * rename 4 * rename 5 * rm dead file * rename 6 * rename 7 * rename 8 * restore comment * nicer name * complexity notes * more tests * dynamic section * rename * gaurd max * update comments * drop branch * drop template
1 parent c0403af commit 74b7eaf

26 files changed

Lines changed: 1266 additions & 294 deletions

.codespellrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[codespell]
2-
builtin = clear,rare,en-GB_to_en-US,names,informal,code
2+
builtin = clear,rare,names,informal,code
33
check-filenames =
44
check-hidden =
55
ignore-words-list = deque,warmup,stdio,copyable,combinate

AGENTS.md

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -103,34 +103,6 @@ All tests should pass. If tests fail, check that:
103103
- Build completed without errors
104104
- Any changes you have made are correct
105105

106-
## Linting & Validation
107-
108-
The CI runs two linting tools that you should run before committing:
109-
110-
### codespell (spelling)
111-
112-
```bash
113-
codespell
114-
```
115-
116-
Config: `.codespellrc` (ignores: build/, .git/, etc.)
117-
Should produce no output if passing.
118-
119-
### clang-format (code formatting)
120-
121-
```bash
122-
find src include test benchmark/src -name "*.cpp" -o -name "*.hpp" -o -name "*.cxx" | xargs clang-format --dry-run --Werror
123-
```
124-
125-
Config: `.clang-format` (110 column limit, specific style)
126-
Should produce no output if passing.
127-
128-
**To auto-fix formatting**:
129-
130-
```bash
131-
find src include test benchmark/src -name "*.cpp" -o -name "*.hpp" -o -name "*.cxx" | xargs clang-format -i
132-
```
133-
134106
## Project Structure
135107

136108
### Source Layout
@@ -150,10 +122,9 @@ libfork/
150122
│ ├── batteries/ # libfork.batteries — stacks, contexts, adaptors
151123
│ │ ├── batteries.cxx # aggregator
152124
│ │ └── *.cxx # :partitions
153-
── schedulers/ # libfork.schedulers — concrete schedulers
125+
── schedulers/ # libfork.schedulers — concrete schedulers
154126
│ │ ├── schedulers.cxx # aggregator
155127
│ │ └── *.cxx # :partitions
156-
│ └── exception.cpp # terminate_with() implementation
157128
├── test/src/**/ # Test suite (Catch2) — uses `import libfork;`
158129
│ └── *.cpp
159130
├── benchmark/src/ # Benchmarking suite (google-benchmark)
@@ -189,7 +160,6 @@ All workflows follow this pattern:
189160
1. **Modify source files** in `src/`, `include/`, `test/`, or `benchmark/`
190161
2. **Rebuild**: `cmake --build --preset <your-preset>`
191162
3. **Test**: `ctest --preset <your-preset>`
192-
4. **Lint**: Run codespell and clang-format checks
193163

194164
#### Adding/removing files from `src/` or `include/`
195165

@@ -230,11 +200,3 @@ rm -rf build/
230200

231201
**Problem**: "Could not automatically find libc++.modules.json"
232202
**Solution**: Ensure LLVM is installed via Homebrew; toolchain auto-detects the path
233-
234-
### Linting Failures
235-
236-
**Problem**: clang-format errors
237-
**Solution**: Run fix command above to auto-format code
238-
239-
**Problem**: codespell errors
240-
**Solution**: Fix typos or add to ignore list in `.codespellrc` if false positive

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ set(CMAKE_CXX_MODULE_STD 1)
3131
add_library(libfork_libfork)
3232
add_library(libfork::libfork ALIAS libfork_libfork)
3333

34-
# target_link_libraries(libfork_libfork PRIVATE Threads::Threads)
34+
target_link_libraries(libfork_libfork PUBLIC Threads::Threads)
3535

3636
set_property(TARGET libfork_libfork PROPERTY EXPORT_NAME libfork)
3737

@@ -84,6 +84,7 @@ target_sources(libfork_libfork
8484
src/core/execute.cxx
8585
src/core/receiver.cxx
8686
src/core/promise.cxx
87+
src/core/stop.cxx
8788
# libfork.batteries
8889
src/batteries/batteries.cxx
8990
src/batteries/deque.cxx

benchmark/CMakeLists.txt

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 4.2.1 FATAL_ERROR)
22

3-
project(libfork_benchmark LANGUAGES C CXX)
3+
project(libfork_benchmark LANGUAGES CXX)
44

55
if(NOT CMAKE_BUILD_TYPE STREQUAL "Release")
66
message(WARNING "It is recommended to build benchmarks in Release mode for accurate results.")
@@ -17,7 +17,8 @@ target_link_libraries(libfork_benchmark
1717
benchmark::benchmark_main
1818
)
1919

20-
# Common headers
20+
# Common components
21+
2122
target_sources(libfork_benchmark
2223
PRIVATE
2324
FILE_SET HEADERS FILES
@@ -28,18 +29,13 @@ target_sources(libfork_benchmark
2829
src
2930
)
3031

31-
# Common sources
3232
target_sources(libfork_benchmark
3333
PRIVATE
3434
src/libfork_benchmark/uts/uts.cpp
3535
)
3636

37-
3837
# C lib for UTS
39-
add_library(uts_c OBJECT
40-
src/libfork_benchmark/uts/external/uts.c
41-
src/libfork_benchmark/uts/external/rng/brg_sha1.c
42-
)
38+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/external/uts external/uts)
4339

4440
target_link_libraries(libfork_benchmark PRIVATE uts_c)
4541

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
cmake_minimum_required(VERSION 4.2.1 FATAL_ERROR)
2+
3+
project(uts_external LANGUAGES C)
4+
5+
add_library(uts_c)
6+
7+
target_sources(uts_c
8+
PRIVATE
9+
src/uts.c
10+
src/rng/brg_sha1.c
11+
PUBLIC
12+
FILE_SET HEADERS
13+
BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include
14+
FILES
15+
include/uts/uts.h
16+
include/uts/rng/rng.h
17+
include/uts/rng/brg_sha1.h
18+
include/uts/rng/brg_types.h
19+
)

benchmark/src/libfork_benchmark/uts/external/rng/brg_sha1.h renamed to benchmark/external/uts/include/uts/rng/brg_sha1.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#ifndef _SHA1_H
3434
#define _SHA1_H
3535

36-
#include "brg_types.h"
36+
#include "uts/rng/brg_types.h"
3737

3838
#define SHA1_BLOCK_SIZE 64
3939
#define SHA1_DIGEST_SIZE 20

benchmark/src/libfork_benchmark/uts/external/rng/brg_types.h renamed to benchmark/external/uts/include/uts/rng/brg_types.h

File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#ifndef _RNG_H
22
#define _RNG_H
33

4-
#include "brg_sha1.h"
4+
#include "uts/rng/brg_sha1.h"
55

66
#endif /* _RNG_H */

benchmark/src/libfork_benchmark/uts/external/uts.h renamed to benchmark/external/uts/include/uts/uts.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
extern "C" {
2323
#endif
2424

25-
#include "rng/rng.h"
25+
#include "uts/rng/rng.h"
2626

2727
#define UTS_VERSION "2.1"
2828

File renamed without changes.

0 commit comments

Comments
 (0)