Skip to content

Commit 77e3d03

Browse files
Merge houliston/scheduler and integrate typed priorities with lock-free scheduler.
Rebase was abandoned after conflicts across 73 commits; merge scheduler into priority-changes instead. Maps the seven-level PriorityLevel DSL enum onto five scheduler buckets, keeps ThreadPriority RAII, and updates scheduler/Group/Pool code paths and docs for the typed priority model. Co-authored-by: Cursor <cursoragent@cursor.com>
2 parents 2c65b6c + c53c2a9 commit 77e3d03

157 files changed

Lines changed: 14835 additions & 5635 deletions

File tree

Some content is hidden

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

.github/copilot-instructions.md

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# GitHub Copilot Instructions
2+
3+
This repository contains NUClear — a C++ reactive framework for robot software.
4+
5+
## Project Overview
6+
7+
NUClear is a C++14 message-passing framework built around reactive programming.
8+
Reactors define event-driven callbacks using a domain-specific language (DSL) of template words.
9+
The framework handles threading, scheduling, and data routing automatically.
10+
11+
### Core Components
12+
13+
- **PowerPlant**: Top-level container that manages the system lifecycle
14+
- **Reactor**: Base class for user modules that define reactions
15+
- **DSL Words**: Template parameters that define triggering and data access (`Trigger`, `With`, `Every`, etc.)
16+
- **Threading**: Pool-based scheduler with priority queuing and group synchronisation
17+
- **Extensions**: Plugin system for IO, networking, timers, and tracing
18+
19+
### Build System
20+
21+
- CMake with C++14 target (`cxx_std_14`)
22+
- Catch2 for unit testing (fetched via CMake)
23+
- Platform support: Linux, macOS, Windows
24+
25+
## Code Quality Standards
26+
27+
- **Language Standard**: C++14 (do not use C++17 or later features)
28+
- **Formatting**: clang-format
29+
- **Linting**: clang-tidy (config in `cmake/ClangTidy.cmake`)
30+
- **Testing**: Catch2, run via CTest
31+
- **Language**: American English for all code, comments, and documentation
32+
33+
### Code Style
34+
35+
- **Clean Changes**: When making changes don't leave behind comments describing what was once there; comments should always describe code as it exists
36+
- **API Evolution**: When making changes don't leave behind backwards-compatible interfaces for internal APIs; there should always be a complete clean changeover
37+
- **Property Access**: Assume fields that should exist do exist directly; rely on errors if they don't rather than adding unnecessary null checks
38+
39+
## Documentation Standards
40+
41+
Documentation lives in `docs/` and is built with MkDocs Material.
42+
All documentation files are Markdown.
43+
44+
### Markdown Formatting
45+
46+
- **Formatter**: mdformat (config in `pyproject.toml`)
47+
- **Semantic Line Breaks**: Follow the [Semantic Line Breaks specification (SemBr)](https://sembr.org/)
48+
- One sentence per line
49+
- Break after sentences (`.`, `!`, `?`)
50+
- Break after independent clauses (`,`, `;`, `:`, ``) when it improves readability
51+
- Break after dependent clauses for clarity when lines are long
52+
- **Never break lines based on column count**
53+
- If a line exceeds ~120 characters, consider simplifying the prose rather than wrapping mid-sentence
54+
- Example:
55+
```markdown
56+
NUClear is a reactive framework for building modular robot software.
57+
It uses a domain-specific language embedded in C++ templates to define event-driven callbacks.
58+
59+
Each module is a Reactor that declares what data it needs,
60+
and the framework handles threading and scheduling automatically.
61+
```
62+
63+
### Writing Style
64+
65+
- **Tone**: Friendly and informative
66+
- **Perspective**: Use second-person ("you" and "your") for user-facing documentation
67+
- **Language**: American English with sentence case for titles
68+
- **Clarity**: Write for non-native English speakers; avoid jargon without explanation
69+
- **Formatting in prose**:
70+
- Use backticks for: type names, function names, file paths, DSL words, template parameters
71+
- Use sentence case for headings (capitalize only the first word and proper nouns)
72+
- Avoid abbreviations when possible
73+
74+
### Documentation Structure (Diátaxis)
75+
76+
The docs follow the [Diátaxis framework](https://diataxis.fr/):
77+
78+
| Section | Purpose | Path |
79+
| -------------- | ------------------------------------ | ------------------ |
80+
| Getting started | Tutorials for new users | `getting-started/` |
81+
| Concepts | Explanation of architecture | `concepts/` |
82+
| How-to guides | Task-oriented recipes | `how-to/` |
83+
| Reference | Complete DSL/API reference | `reference/` |
84+
| Explanation | Deep-dive background material | `explanation/` |
85+
| Contributing | Developer setup and style guide | `contributing/` |
86+
87+
### Code Examples in Documentation
88+
89+
- All C++ examples should compile conceptually (correct syntax, proper includes)
90+
- Use `#include "nuclear"` as the canonical include
91+
- Examples should be self-contained where possible
92+
- Verify API usage against source code — do not guess signatures or return types
93+
94+
### Documentation Tooling
95+
96+
```bash
97+
# Install docs dependencies
98+
uv sync --group docs
99+
100+
# Preview documentation
101+
uv run mkdocs serve
102+
103+
# Format all markdown files
104+
uv sync --group dev
105+
uv run mdformat docs/
106+
```
107+
108+
## Development Workflow
109+
110+
### Building
111+
112+
```bash
113+
mkdir build && cd build
114+
cmake .. -GNinja
115+
ninja
116+
```
117+
118+
### Testing
119+
120+
```bash
121+
cd build
122+
ctest
123+
```
124+
125+
### Documentation Development
126+
127+
```bash
128+
uv sync --group docs --group dev
129+
uv run mkdocs serve # Live preview at http://127.0.0.1:8000
130+
uv run mdformat docs/ # Format markdown
131+
```

.github/workflows/linting.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,20 @@ jobs:
9797

9898
- name: CTCache Stats
9999
run: clang-tidy-cache --show-stats
100+
101+
markdown-format:
102+
name: Markdown Formatting
103+
runs-on: ubuntu-latest
104+
105+
steps:
106+
- name: Checkout Code
107+
uses: actions/checkout@v4
108+
109+
- name: Install uv
110+
uses: astral-sh/setup-uv@v4
111+
112+
- name: Install dependencies
113+
run: uv sync --group dev
114+
115+
- name: Check markdown formatting
116+
run: uv run mdformat --check docs/

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
# Build & CMake files
1616
build/
17+
build-*/
1718
CMakeCache.txt
1819
CMakeFiles
1920
Makefile
@@ -28,3 +29,7 @@ docs/doxygen
2829
docs/doxygen_sqlite3.db
2930
*.sublime-workspace
3031
.DS_Store
32+
site/
33+
.venv/
34+
35+
site/

.readthedocs.yaml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
1-
# .readthedocs.yaml
21
# Read the Docs configuration file
3-
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
2+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html
43

5-
# Required
64
version: 2
75

8-
# Set the version of Python and other tools you might need
96
build:
107
os: ubuntu-22.04
118
tools:
12-
python: "3.11"
9+
python: "3.12"
10+
apt_packages:
11+
- doxygen
1312

14-
# Build documentation in the docs/ directory with Sphinx
15-
sphinx:
16-
configuration: docs/conf.py
13+
mkdocs:
14+
configuration: mkdocs.yml
1715

18-
# We recommend specifying your dependencies to enable reproducible builds:
19-
# https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
2016
python:
2117
install:
22-
- requirements: docs/requirements.txt
18+
- requirements: docs/requirements.txt

.vscode/settings.json

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,68 @@
1515
"sonarlint.connectedMode.project": {
1616
"connectionId": "fastcode",
1717
"projectKey": "Fastcode_NUClear"
18+
},
19+
"files.associations": {
20+
"__bit_reference": "cpp",
21+
"__config": "cpp",
22+
"__hash_table": "cpp",
23+
"__locale": "cpp",
24+
"__node_handle": "cpp",
25+
"__split_buffer": "cpp",
26+
"__threading_support": "cpp",
27+
"__tree": "cpp",
28+
"__verbose_abort": "cpp",
29+
"array": "cpp",
30+
"bitset": "cpp",
31+
"cctype": "cpp",
32+
"charconv": "cpp",
33+
"clocale": "cpp",
34+
"cmath": "cpp",
35+
"complex": "cpp",
36+
"condition_variable": "cpp",
37+
"csignal": "cpp",
38+
"cstdarg": "cpp",
39+
"cstddef": "cpp",
40+
"cstdint": "cpp",
41+
"cstdio": "cpp",
42+
"cstdlib": "cpp",
43+
"cstring": "cpp",
44+
"ctime": "cpp",
45+
"cwchar": "cpp",
46+
"cwctype": "cpp",
47+
"deque": "cpp",
48+
"execution": "cpp",
49+
"fstream": "cpp",
50+
"future": "cpp",
51+
"initializer_list": "cpp",
52+
"iomanip": "cpp",
53+
"ios": "cpp",
54+
"iosfwd": "cpp",
55+
"iostream": "cpp",
56+
"istream": "cpp",
57+
"limits": "cpp",
58+
"list": "cpp",
59+
"locale": "cpp",
60+
"map": "cpp",
61+
"mutex": "cpp",
62+
"new": "cpp",
63+
"optional": "cpp",
64+
"ostream": "cpp",
65+
"ratio": "cpp",
66+
"regex": "cpp",
67+
"set": "cpp",
68+
"sstream": "cpp",
69+
"stack": "cpp",
70+
"stdexcept": "cpp",
71+
"streambuf": "cpp",
72+
"string": "cpp",
73+
"string_view": "cpp",
74+
"tuple": "cpp",
75+
"typeindex": "cpp",
76+
"typeinfo": "cpp",
77+
"unordered_map": "cpp",
78+
"variant": "cpp",
79+
"vector": "cpp",
80+
"algorithm": "cpp"
1881
}
1982
}

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,13 @@ if(CI_BUILD)
8181
endif()
8282
endif(CI_BUILD)
8383

84+
# Tests must be declared before src/ so NUClear can expose test-only APIs when enabled.
85+
option(BUILD_TESTS "Builds all of the NUClear unit tests." ON)
86+
8487
# Add the src directory
8588
add_subdirectory(src)
8689

8790
# Add the tests directory
88-
option(BUILD_TESTS "Builds all of the NUClear unit tests." ON)
8991
if(BUILD_TESTS)
9092
enable_testing()
9193
add_subdirectory(tests)

cmake/TestRunner.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ foreach(target ${all_targets})
5454
list(APPEND report_outputs ${junit_report_file})
5555
add_custom_command(
5656
OUTPUT ${junit_report_file} ${raw_coverage}
57-
COMMAND ${command_prefix} $<TARGET_FILE:${target}> --reporter console --reporter JUnit::out=${junit_report_file}
57+
COMMAND ${command_prefix} $<TARGET_FILE:${target}> --allow-running-no-tests --reporter console
58+
--reporter JUnit::out=${junit_report_file}
5859
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
5960
DEPENDS ${target}
6061
USES_TERMINAL

docs/.special.rst

Lines changed: 0 additions & 40 deletions
This file was deleted.

docs/CMakeLists.txt

Lines changed: 0 additions & 37 deletions
This file was deleted.

docs/Doxyfile

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)