-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add unique_resource
#16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Test Results 5 files 5 suites 37s ⏱️ Results for commit 6c5a909. ♻️ This comment has been updated with latest results. |
70f88bf
to
594c628
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #16 +/- ##
==========================================
+ Coverage 78.87% 84.71% +5.84%
==========================================
Files 1 2 +1
Lines 71 157 +86
Branches 15 23 +8
==========================================
+ Hits 56 133 +77
- Partials 15 24 +9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
a336c28
to
18a6066
Compare
|
18a6066
to
6c5a909
Compare
|
@coderabbitai summary |
@coderabbitai review |
✅ Actions performedSummary regeneration triggered. |
Warning Rate limit exceeded@sjinks has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 14 minutes and 20 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (9)
WalkthroughA new resource management utility, Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant unique_resource
participant Resource
participant Deleter
User->>unique_resource: Construct with Resource, Deleter
unique_resource->>Resource: Store handle
unique_resource->>Deleter: Store deleter
User->>unique_resource: Use resource via get(), operator*
User->>unique_resource: release() / reset() / destruction
alt Resource owned
unique_resource->>Deleter: Call deleter(resource)
Deleter-->>Resource: Release/dispose
else Resource released
unique_resource-->>Deleter: No action
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Actions performedReview triggered.
|
Note Unit test generation is an Early Access feature. Expect some limitations and changes as we gather feedback and continue to improve it. Generating unit tests... This may take up to 20 minutes. |
There was a problem hiding this 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 new unique_resource
utility for universal RAII resource management, providing safe and automatic resource cleanup with custom deleters. The implementation follows the C++ Library Fundamentals Technical Specification pattern for managing resources through handles.
Key changes include:
- Added a comprehensive
unique_resource
class template with move semantics and exception safety - Implemented factory function
make_unique_resource_checked
for conditional resource ownership - Enhanced documentation and examples demonstrating file and socket management
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
src/unique_resource.h | Core implementation of unique_resource class template with RAII semantics and custom deleters |
test/unique_resource.cpp | Comprehensive unit tests covering construction, move semantics, assignment, and exception safety |
examples/unique_resource.cpp | Example demonstrating file and socket resource management |
test/CMakeLists.txt | Added new test file to build configuration |
examples/CMakeLists.txt | Added unique_resource example to build system |
test/.clang-tidy | Disabled owning-memory warnings for test code |
examples/.clang-tidy | Disabled owning-memory warnings for example code |
README.md | Updated documentation with unique_resource usage examples and API reference |
.github/workflows/ci-vcpkg.yml | Removed commented-out AppleClang configuration |
|
||
/** | ||
* @example unique_resource.cpp | ||
* Example of using `unqiue_resource` and `make_unique_resource_checked`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The word "unqiue_resource" contains a typo. It should be "unique_resource".
* Example of using `unqiue_resource` and `make_unique_resource_checked`. | |
* Example of using `unique_resource` and `make_unique_resource_checked`. |
Copilot uses AI. Check for mistakes.
unique_resource( | ||
Res&& r, Del&& d, dummy_scope_guard dummy | ||
) noexcept(std::is_nothrow_constructible_v<Resource, Res> && std::is_nothrow_constructible_v<Deleter, Del>) | ||
: m_resource(std::forward<Res>(r), dummy), m_deleter(std::forward<Deleter>(d), dummy) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The deleter is being constructed with std::forward<Deleter>(d)
but the parameter type is Del&&
, not Deleter&&
. This should be std::forward<Del>(d)
to properly forward the deleter parameter.
: m_resource(std::forward<Res>(r), dummy), m_deleter(std::forward<Deleter>(d), dummy) | |
: m_resource(std::forward<Res>(r), dummy), m_deleter(std::forward<Del>(d), dummy) |
Copilot uses AI. Check for mistakes.
Copilot-Generated SummaryThis pull request introduces the New Feature:
|
✅ UTG Post-Process Complete No new issues were detected in the generated code and all check runs have completed. The unit test generation process has completed successfully. |
Creating a PR to put the unit tests in... The changes have been created in this pull request: View PR |
@coderabbitai full review |
✅ Actions performedFull review triggered. |
Summary by CodeRabbit
New Features
unique_resource
, for safe and automatic resource cleanup with custom deleters.unique_resource
instances that only take ownership if the resource is valid.Documentation
unique_resource
.Examples
unique_resource
for managing files and sockets.Tests
unique_resource
covering creation, ownership transfer, release, reset, and exception safety.Chores