Skip to content

Conversation

@pawelrutkaq
Copy link
Contributor

  • UT will be added after the first review round
  • Deadlines not yet allocated in the right place

Closes #14

@github-actions
Copy link

github-actions bot commented Jan 22, 2026

License Check Results

🚀 The license check job ran with the Bazel command:

bazel run //:license-check

Status: ⚠️ Needs Review

Click to expand output
[License Check Output]
Extracting Bazel installation...
Starting local Bazel server (8.4.2) and connecting to it...
INFO: Invocation ID: 1c882e37-87e0-4012-981d-c645997e6b69
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
DEBUG: Rule 'rust_qnx8_toolchain+' indicated that a canonical reproducible form can be obtained by modifying arguments integrity = "sha256-eQOopREOYCL5vtTb6c1cwZrql4GVrJ1FqgxarQRe1xs="
DEBUG: Repository rust_qnx8_toolchain+ instantiated at:
  <builtin>: in <toplevel>
Repository rule http_archive defined at:
  /home/runner/.bazel/external/bazel_tools/tools/build_defs/repo/http.bzl:431:31: in <toplevel>
Computing main repo mapping: 
Computing main repo mapping: 
Loading: 
Loading: 2 packages loaded
Loading: 2 packages loaded
    currently loading: 
Loading: 2 packages loaded
    currently loading: 
Loading: 2 packages loaded
    currently loading: 
Analyzing: target //:license-check (3 packages loaded, 0 targets configured)
Analyzing: target //:license-check (3 packages loaded, 0 targets configured)

Analyzing: target //:license-check (33 packages loaded, 10 targets configured)

Analyzing: target //:license-check (89 packages loaded, 10 targets configured)

Analyzing: target //:license-check (116 packages loaded, 198 targets configured)

Analyzing: target //:license-check (147 packages loaded, 2628 targets configured)

Analyzing: target //:license-check (148 packages loaded, 5453 targets configured)

Analyzing: target //:license-check (152 packages loaded, 7398 targets configured)

Analyzing: target //:license-check (152 packages loaded, 7398 targets configured)

Analyzing: target //:license-check (162 packages loaded, 13697 targets configured)

INFO: Analyzed target //:license-check (162 packages loaded, 13697 targets configured).
INFO: Found 1 target...
Target //:license.check.license_check up-to-date:
  bazel-bin/license.check.license_check
  bazel-bin/license.check.license_check.jar
INFO: Elapsed time: 26.271s, Critical Path: 0.38s
INFO: 13 processes: 4 disk cache hit, 9 internal.
INFO: Build completed successfully, 13 total actions
INFO: Running command line: bazel-bin/license.check.license_check ./formatted.txt <args omitted>
usage: org.eclipse.dash.licenses.cli.Main [-batch <int>] [-cd <url>]
       [-confidence <int>] [-ef <url>] [-excludeSources <sources>] [-help] [-lic
       <url>] [-project <shortname>] [-repo <url>] [-review] [-summary <file>]
       [-timeout <seconds>] [-token <token>]

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a C++ FFI (Foreign Function Interface) API for deadline monitoring functionality in the health monitoring library. The changes enable C++ code to interact with the Rust-based deadline monitoring system through a well-defined interface.

Changes:

  • Added FFI bindings in Rust to expose deadline monitoring functionality to C++
  • Implemented C++ wrapper classes (HealthMonitor, DeadlineMonitor, Deadline) that interface with the Rust backend
  • Created build configuration for compiling both Rust static library and C++ library components

Reviewed changes

Copilot reviewed 20 out of 22 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/health_monitoring_lib/src/lib.rs Added HealthMonitor and HealthMonitorBuilder structs to manage deadline monitors
src/health_monitoring_lib/src/ffi.rs New FFI functions for health monitor builder creation, destruction, and deadline monitor management
src/health_monitoring_lib/src/deadline/ffi.rs New FFI functions for deadline monitor operations including builder, monitor, and deadline lifecycle management
src/health_monitoring_lib/src/deadline/deadline_monitor.rs Refactored deadline monitoring to support FFI usage with internal helper methods
src/health_monitoring_lib/src/common.rs Changed IdentTag to FFI-compatible representation and added FFI helper utilities
src/health_monitoring_lib/cpp/include/score/hm/health_monitor.h C++ header defining HealthMonitor and HealthMonitorBuilder classes
src/health_monitoring_lib/cpp/include/score/hm/deadline/deadline_monitor.h C++ header defining deadline monitoring classes (DeadlineMonitor, Deadline, DeadlineHandle)
src/health_monitoring_lib/cpp/include/score/hm/common.h C++ header with common types including IdentTag, TimeRange, and FFI helpers
src/health_monitoring_lib/cpp/health_monitor.cpp Implementation of C++ HealthMonitor classes
src/health_monitoring_lib/cpp/deadline/deadline_monitor.cpp Implementation of C++ deadline monitoring classes
src/health_monitoring_lib/cpp/common.cpp Implementation of DroppableFFIHandle utility class
src/health_monitoring_lib/cpp/ffi_helpers.h Helper function to convert Rust error codes to C++ Error enum
src/health_monitoring_lib/cpp/tests/health_monitor_test.cpp Basic test demonstrating the C++ API usage
src/health_monitoring_lib/BUILD Updated build configuration to include Rust static library and C++ library targets
Comments suppressed due to low confidence (1)

src/health_monitoring_lib/src/deadline/ffi.rs:1

  • Corrected grammar from 'This function is provides' to 'This function is provided'.
use crate::common::ffi::*;

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link

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

@pawelrutkaq pawelrutkaq force-pushed the pawelrutkaq_deadline_monitor_cpp branch from c1dd35a to 28fbfd4 Compare January 22, 2026 14:24
@pawelrutkaq pawelrutkaq force-pushed the pawelrutkaq_deadline_monitor_cpp branch from 28fbfd4 to b9c92b8 Compare January 22, 2026 14:25
@pawelrutkaq
Copy link
Contributor Author

I will fix QNX8 after first review rounds

Copy link

@arkjedrz arkjedrz left a comment

Choose a reason for hiding this comment

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

Mostly nitpicks, but error handling can definitely be improved.

Choose a reason for hiding this comment

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

Missing empty line.


## IDE support

### C++

Choose a reason for hiding this comment

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

I recommend markdownlint for Markdown linting.

  • Missing newline after section.
  • Prefer single sentence per line.


bazel_dep(name = "score_baselibs_rust", version = "0.0.3")
bazel_dep(name = "score_baselibs", version = "0.2.2")
# git_override(

Choose a reason for hiding this comment

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

Unnecessary?

use_repo(toolchains_qnx, "toolchains_qnx_ifs")

bazel_dep(name = "score_baselibs_rust", version = "0.0.3")
bazel_dep(name = "score_baselibs", version = "0.2.2")

Choose a reason for hiding this comment

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

Why moved here?

*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
#ifndef SCORE_HM_DEADLINE_DEADLINE_MONITOR_H

Choose a reason for hiding this comment

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

Why not #pragma once?


auto deadline_mon = std::move(*deadline_monitor_res);

// std::cout << "Getting deadline" << std::endl;

Choose a reason for hiding this comment

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

Leftover.

unsafe { self.start_internal().map(|_| DeadlineHandle(self)) }
}

/// Starts the deadline - it will be monitored by health monitoring system.

Choose a reason for hiding this comment

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

/// Starts the deadline - it will be monitored by health monitoring system.
/// This function is for FFI usage only!
///
/// # Safety
///
/// Caller must ensure that deadline is not used until it's stopped.
/// After this call You shall assure there's only a single owner of the `Deadline` instance and it does not call start before stopping.

public:
HealthMonitor(const HealthMonitor&) = delete;
HealthMonitor& operator=(const HealthMonitor&) = delete;
HealthMonitor(HealthMonitor&& other)

Choose a reason for hiding this comment

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

Move impl to cpp.

}
}

mod ffi;

Choose a reason for hiding this comment

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

Merge mod and use blocks.

Choose a reason for hiding this comment

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

Move this file to parent and remove deadline/ directory. .cpp files don't necessarily have to follow Rust module structure, and it's already messy with include/ dir.

Choose a reason for hiding this comment

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

In general I'm not against committing editor config files into repo, but this makes sense if we all use the same editor.

Maybe this file should be on the git ignore list?

],
)

cc_gtest_unit_test(
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure what the expectations are but the score module template is placing all tests in /tests, maybe this should be discussed what convention is used in weekly sync

Copy link
Contributor

Choose a reason for hiding this comment

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

FYI I've been using the cli tool bazel-compile-commands and works better for me. It's also mentioned in the official bazel docs https://bazel.build/install/ide#c_language_family_c_c_objective-c_objective-c_and_cuda

#include "score/hm/deadline/deadline_monitor.h"
#include "ffi_helpers.h"

extern "C" {

Choose a reason for hiding this comment

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

Is there a reason why this C interface is not declared in its own header?

At the moment it is hard to follow this code, but I understand it to work like this:

  • We have core implementation in Rust.
  • Then we have Foreign Function Interface (FFI) around that.
  • Finally we have intended Cpp interface that is linked with FFI library.

I could be wrong above, but if I'm right, I would prefer to have folder and file structure organized around that. That should allow us to see boundaries easier and also should make build files a bit easier.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[HmLib] C++ Deadline Monitor API

4 participants