Skip to content

const overloads & nodiscard for LockedPtr members#377

Open
sankurm wants to merge 1 commit into
eclipse-score:mainfrom
sankurm:locked_ptr_const_nodiscard_fns
Open

const overloads & nodiscard for LockedPtr members#377
sankurm wants to merge 1 commit into
eclipse-score:mainfrom
sankurm:locked_ptr_const_nodiscard_fns

Conversation

@sankurm

@sankurm sankurm commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

This prepares the LockedPtr for the monadic interface that it should have. The support functions

  1. make the return of functions mandatory to handle [[nodiscard]]
  2. Ensure that const overloads are supported (needed for further upcoming functionality)

@github-actions

Copy link
Copy Markdown

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

@sankurm
sankurm force-pushed the locked_ptr_const_nodiscard_fns branch from b16531d to 86b1194 Compare July 15, 2026 12:53
@sankurm
sankurm temporarily deployed to workflow-approval July 15, 2026 12:53 — with GitHub Actions Inactive
@sankurm
sankurm temporarily deployed to workflow-approval July 15, 2026 12:53 — with GitHub Actions Inactive
@4og
4og requested review from Copilot and fbaeuerle July 16, 2026 07:56

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

This PR updates score::concurrency::LockedPtr to better support const-correct access patterns and to encourage correct usage via [[nodiscard]], in preparation for upcoming “monadic interface” work.

Changes:

  • Added [[nodiscard]] to operator*() / operator->() and introduced missing const overloads for both.
  • Split get() into const/non-const overloads and made the const overload return const T*.
  • Added a const overload of unlock_guard() and made the stored lock mutable to support that overload.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
score/concurrency/locked_ptr.h Adds [[nodiscard]] and const overloads for pointer-like accessors; enables unlock_guard() on const instances via mutable lock storage.
score/concurrency/locked_ptr_test.cpp Reworks/extends tests to cover the new const overloads and [[nodiscard]]-motivated API changes.

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

Comment on lines +162 to +166
{
auto cug_mut = std::as_const(lp_mut).unlock_guard();
EXPECT_TRUE((std::is_same_v<decltype(cug_mut), UnlockGuard<std::unique_lock<std::mutex>>>))
<< "unlock_guard() should return UnlockGuard<std::unique_lock<std::mutex>>";
}

@fbaeuerle fbaeuerle left a comment

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.

i'd like to see copilots suggestion implemented (i.e. testing the behavior also for the const version)

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

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

4 participants