Skip to content

Add Rust wrapper for score::cpp::stop_token - #461

Open
eclipse-impl wants to merge 1 commit into
eclipse-score:mainfrom
eclipse-impl:swp-271167
Open

Add Rust wrapper for score::cpp::stop_token#461
eclipse-impl wants to merge 1 commit into
eclipse-score:mainfrom
eclipse-impl:swp-271167

Conversation

@eclipse-impl

Copy link
Copy Markdown
Contributor

No description provided.

@eclipse-impl
eclipse-impl deployed to workflow-approval August 11, 2026 15:24 — with GitHub Actions Active
@eclipse-impl
eclipse-impl deployed to workflow-approval August 11, 2026 15:24 — with GitHub Actions Active
@eclipse-impl
eclipse-impl deployed to workflow-approval August 11, 2026 15:24 — with GitHub Actions Active
@eclipse-impl
eclipse-impl deployed to workflow-approval August 11, 2026 15:24 — with GitHub Actions Active
@github-actions

Copy link
Copy Markdown
Contributor

The created documentation from the pull request is available at: docu-html

@4og
4og requested a balanced review from Copilot August 13, 2026 12:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds CXX-based Rust bindings for FutureCpp stop tokens and sources.

Changes:

  • Exposes stop-state creation, querying, equality, and cancellation.
  • Adds C++ bridge adapters and Rust unit tests.
  • Integrates the crate with Bazel and Cargo.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
score/language/rust/stop_token/src/lib.rs Implements the Rust API and tests.
score/language/rust/stop_token/cpp/stop_token_adapter.h Declares C++ bridge functions.
score/language/rust/stop_token/cpp/stop_token_adapter.cpp Implements FutureCpp forwarding.
score/language/rust/stop_token/Cargo.toml Defines the Rust crate.
score/language/rust/stop_token/BUILD Adds Bazel bridge, library, and test targets.
Cargo.toml Registers the workspace member.
Cargo.lock Locks the new CXX dependency graph.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread Cargo.toml
"score/testing_macros",
"score/language/rust/libcpp",
"score/language/rust/libcpp_derive",
"score/language/rust/stop_token",
Comment on lines +92 to +95
unsafe impl Send for StopToken {}
unsafe impl Sync for StopToken {}
unsafe impl Send for StopSource {}
unsafe impl Sync for StopSource {}
#ifndef SCORE_LANGUAGE_RUST_STOP_TOKEN_CPP_STOP_TOKEN_ADAPTER_H
#define SCORE_LANGUAGE_RUST_STOP_TOKEN_CPP_STOP_TOKEN_ADAPTER_H

#include <score/stop_token.hpp>
bool StopSourceRequestStop(const score::cpp::stop_source& source) noexcept
{
// request_stop() only updates the shared stop state atomically.
return const_cast<score::cpp::stop_source&>(source).request_stop();
Comment thread Cargo.toml
"score/testing_macros",
"score/language/rust/libcpp",
"score/language/rust/libcpp_derive",
"score/language/rust/stop_token",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when You cargo build the project?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it works:

$ cargo build
   Compiling score_log_fmt v0.0.1 (/home/q474126/code/eclipse-score-baselibs/score/log_rust/score_log_fmt)
   Compiling foldhash v0.2.0
   Compiling memres v0.0.1 (/home/q474126/code/eclipse-score-baselibs/score/language/rust/memres)
   Compiling libc v0.2.189
   Compiling syn v2.0.119
   Compiling link-cplusplus v1.0.12
warning: missing documentation for a struct field
   --> score/language/rust/memres/src/lib.rs:141:17
    |
141 |     Monotonic { size: usize },
    |                 ^^^^^^^^^^^
    |
    = note: requested on the command line with `-W missing-docs`

warning: `memres` (lib) generated 1 warning
   Compiling cxx v1.0.199
   Compiling stop_token v0.0.1 (/home/q474126/code/eclipse-score-baselibs/score/language/rust/stop_token)
   Compiling score_log_fmt_macro v0.0.1 (/home/q474126/code/eclipse-score-baselibs/score/log_rust/score_log_fmt_macro)
   Compiling libcpp_derive v0.0.1 (/home/q474126/code/eclipse-score-baselibs/score/language/rust/libcpp_derive)
warning: missing documentation for the crate
   --> score/language/rust/libcpp_derive/lib.rs:14:1
    |
 14 | / use proc_macro2::TokenStream;
 15 | | use quote::{format_ident, quote};
 16 | | use syn::parse::Parse;
 17 | | use syn::spanned::Spanned;
...   |
234 | | }
    | |_^
    |
    = note: requested on the command line with `-W missing-docs`

warning: `libcpp_derive` (lib) generated 1 warning
   Compiling libcpp v0.0.1 (/home/q474126/code/eclipse-score-baselibs/score/language/rust/libcpp)
   Compiling score_log v0.0.1 (/home/q474126/code/eclipse-score-baselibs/score/log_rust/score_log)
   Compiling result_rs v0.0.1 (/home/q474126/code/eclipse-score-baselibs/score/result/rust)
warning: missing documentation for a struct
   --> score/result/rust/result.rs:156:5
    |
156 |     pub struct Expected<T, E> {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: requested on the command line with `-W missing-docs`

   Compiling allocator v0.0.1 (/home/q474126/code/eclipse-score-baselibs/score/allocator)
   Compiling stdout_logger v0.0.1 (/home/q474126/code/eclipse-score-baselibs/score/log_rust/stdout_logger)
   Compiling pal v0.0.1 (/home/q474126/code/eclipse-score-baselibs/score/pal)
warning: `result_rs` (lib) generated 1 warning
   Compiling sync v0.0.1 (/home/q474126/code/eclipse-score-baselibs/score/sync)
   Compiling containers v0.0.1 (/home/q474126/code/eclipse-score-baselibs/score/containers_rust)
   Compiling thread v0.0.1 (/home/q474126/code/eclipse-score-baselibs/score/thread)
   Compiling score_testing_macros v0.0.1 (/home/q474126/code/eclipse-score-baselibs/score/testing_macros)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 2.65s

path = "src/lib.rs"

[dependencies]
cxx = "1.0.186"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace with a regular FFI layer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bazel Bazel and Starlark build files c++ C++ code rust Rust code

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

3 participants