[V4] Public-private split#101
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
47fa125 to
c85ebef
Compare
c2e3a25 to
a70de4b
Compare
format re-introduce so it's not trailing check pass 1 pass 2 format
a70de4b to
dac822b
Compare
4010651 to
dac822b
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (3)
src/core/poly_context.cxx (1)
38-56: Optional: document the defaultpostbehavior.The class-level doc describes
poly_contextas polymorphic inpush/pop/post, but doesn't note that the defaultpostimplementation throwspost_error. Since this is now a non-pure virtual (so derived classes silently inherit the throwing default), a one-line note here will help consumers avoid surprise runtime exceptions when they forget to overridepostin a context they intend to schedule onto.📝 Proposed doc tweak
/** * `@brief` A worker context polymorphic in push/pop/post. * * This is the canonical/blessed base class in libfork for polymorphic uses * cases. Although possible, libfork does not recommend contexts polymorphic * in the `.stack` member + * + * `@note` `push`/`pop` are pure virtual and must be overridden. `post` has a + * default implementation that throws `post_error`; override it in + * derived contexts that should accept externally scheduled tasks. */🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/core/poly_context.cxx` around lines 38 - 56, Add one-line documentation to poly_context explaining that the default implementation of virtual void post(sched_handle<poly_context>) throws post_error; update the class-level comment (or add a brief comment immediately above the post method) to state that post has a throwing default implementation so derived classes that intend to be schedulable must override post to avoid runtime post_error exceptions; reference the poly_context class and its post method in the sentence.src/core/promise.cxx (1)
631-665: Minor: consider also asserting on a non-trivialTto catch alignment regressions.The current set covers
void(noreturn_address) andint(int*). Both have pointer-typedreturn_address, so any pathologicalTthat bumps the promise alignment pastalignof(frame_t)(e.g., an over-aligned type) wouldn't be caught here. Sincereturn_addressis alwaysT*, this is unlikely to ever bite, but a single extra assertion using something likestd::max_align_tor an over-aligned struct would close that gap cheaply.🛡️ Optional extra coverage
static_assert(std::is_standard_layout_v<lf::promise_type<int, unit_context>>); + +struct alignas(alignof(std::max_align_t) * 2) overaligned_t { + int x; +}; +static_assert(alignof(lf::promise_type<overaligned_t, unit_context>) == alignof(frame_t)); +static_assert(std::is_standard_layout_v<lf::promise_type<overaligned_t, unit_context>>);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/core/promise.cxx` around lines 631 - 665, Add an additional static_assert that checks promise alignment for a non-trivial/over-aligned T to catch alignment regressions: instantiate lf::promise_type with a wider type (e.g., std::max_align_t or a custom alignas-overaligned struct) and assert alignof(lf::promise_type<ThatType, unit_context>) == alignof(frame_t); refer to the existing symbols frame_t and lf::promise_type<..., unit_context> so the new assertion sits alongside the current ones for void and int.src/core/thread_locals.cxx (1)
15-15: Nit: typo in TODO comment.
implictaions→implications.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/core/thread_locals.cxx` at line 15, Update the TODO comment in thread_locals.cxx to correct the typo: change "implictaions" to "implications" in the TODO text near the thread-local/constexpr note so the comment reads "TODO: implications of thread local on constexpr".
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docs/api.md`:
- Around line 269-272: The API docs list inline_scheduler<Context> but omit the
two new public template aliases mono_inline_scheduler and poly_inline_scheduler;
update the docs in the inline scheduler section to mention both aliases
alongside inline_scheduler<Context>, describe that they are template aliases
providing convenient default context configurations (used in tests/benchmarks),
and ensure their names and short descriptions appear in the same format as the
existing entry so the documented API surface matches the exported symbols
mono_inline_scheduler and poly_inline_scheduler.
In `@src/core/frame.cxx`:
- Around line 14-25: The build fails because frame_type (template
frame_type<Checkpoint>) was de-exported from the frame partition but promise.cxx
still references it via using frame_t = lf::frame_type<unit_checkpoint>;—restore
access by either re-exporting the template (make the enum class category and
template struct frame_type exported in the module interface so lf::frame_type is
visible) or adjust promise.cxx to use an allowed symbol (e.g., add a
forward-declaration of template<class> frame_type or move the definition into
the public header/interface that defines unit_checkpoint) so that
unit_checkpoint and lf::frame_type are resolvable to satisfy the using
declaration.
In `@src/core/thread_locals.cxx`:
- Around line 12-13: Either export the template variable thread_local_context so
other libfork.core partitions can directly reference it, or refactor the call
sites in execute.cxx (6 occurrences), schedule.cxx, and root.cxx to use the
provided accessors get_tls_context() and get_tls_stack() instead; update those
files to replace direct uses of thread_local_context<Context> with calls to the
getters (or add an export declaration for thread_local_context in this
partition) and also correct the TODO typo from "implictaions" to "implications".
---
Nitpick comments:
In `@src/core/poly_context.cxx`:
- Around line 38-56: Add one-line documentation to poly_context explaining that
the default implementation of virtual void post(sched_handle<poly_context>)
throws post_error; update the class-level comment (or add a brief comment
immediately above the post method) to state that post has a throwing default
implementation so derived classes that intend to be schedulable must override
post to avoid runtime post_error exceptions; reference the poly_context class
and its post method in the sentence.
In `@src/core/promise.cxx`:
- Around line 631-665: Add an additional static_assert that checks promise
alignment for a non-trivial/over-aligned T to catch alignment regressions:
instantiate lf::promise_type with a wider type (e.g., std::max_align_t or a
custom alignas-overaligned struct) and assert alignof(lf::promise_type<ThatType,
unit_context>) == alignof(frame_t); refer to the existing symbols frame_t and
lf::promise_type<..., unit_context> so the new assertion sits alongside the
current ones for void and int.
In `@src/core/thread_locals.cxx`:
- Line 15: Update the TODO comment in thread_locals.cxx to correct the typo:
change "implictaions" to "implications" in the TODO text near the
thread-local/constexpr note so the comment reads "TODO: implications of thread
local on constexpr".
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: bdfe9678-219a-42d4-ac1c-593af3442f19
📒 Files selected for processing (18)
CMakeLists.txtbenchmark/lib/macros.hppbenchmark/src/baremetal/fib.cppbenchmark/src/libfork/fib.cppdocs/api.mdsrc/batteries/batteries.cxxsrc/batteries/contexts.cxxsrc/batteries/deque.cxxsrc/batteries/dummy_stack.cxxsrc/core/concepts/context.cxxsrc/core/frame.cxxsrc/core/poly_context.cxxsrc/core/promise.cxxsrc/core/task.cxxsrc/core/thread_locals.cxxsrc/schedulers/inline.cxxtest/src/concepts.cpptest/src/promise.cpp
💤 Files with no reviewable changes (5)
- src/batteries/batteries.cxx
- CMakeLists.txt
- src/batteries/contexts.cxx
- test/src/promise.cpp
- src/batteries/dummy_stack.cxx
| ### `class inline_scheduler<Context>` — `:inline_scheduler` | ||
|
|
||
| Single-threaded synchronous scheduler. Stores one `Context` instance; `post()` calls `execute()` directly on the calling thread. | ||
|
|
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify whether mono/poly inline scheduler aliases exist in the codebase
# and compare with docs coverage.
set -euo pipefail
echo "== Scheduler symbol definitions/usages =="
rg -n -C2 --iglob '*.{hpp,h,hh,hxx,ipp,cpp,cc,cxx,ixx,cppm,md}' \
'\b(mono_inline_scheduler|poly_inline_scheduler|inline_scheduler)\b'
echo
echo "== docs/api.md scheduler section =="
rg -n -C3 '\b(mono_inline_scheduler|poly_inline_scheduler|inline_scheduler)\b' docs/api.mdRepository: ConorWilliams/libfork
Length of output: 5391
Document the new inline scheduler aliases in the API reference.
Lines 269–272 document inline_scheduler<Context>, but the PR exports two new public template aliases (mono_inline_scheduler and poly_inline_scheduler) that are not listed in the API docs. These aliases provide convenient default context configurations and are actively used in tests and benchmarks. Add them to this section alongside the base template to ensure the documentation matches the exported API surface.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@docs/api.md` around lines 269 - 272, The API docs list
inline_scheduler<Context> but omit the two new public template aliases
mono_inline_scheduler and poly_inline_scheduler; update the docs in the inline
scheduler section to mention both aliases alongside inline_scheduler<Context>,
describe that they are template aliases providing convenient default context
configurations (used in tests/benchmarks), and ensure their names and short
descriptions appear in the same format as the existing entry so the documented
API surface matches the exported symbols mono_inline_scheduler and
poly_inline_scheduler.
Summary by CodeRabbit
Release Notes
New Features
Removed Features
Improvements