-
Notifications
You must be signed in to change notification settings - Fork 38
Add batch write #85
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
Add batch write #85
Conversation
Pull Request Revisions
✅ AI review completed for r2 HelpReact with emojis to give feedback on AI-generated reviews:
We'd love to hear from you—reach out anytime at team@review.ai. |
/** | ||
* @brief Gets the stored value. | ||
* | ||
* @return const T& Reference to the stored value. | ||
* @warning Behavior is undefined if the result holds an error. | ||
*/ | ||
const T& value() const { return value_; } | ||
|
||
/** | ||
* @brief Gets the stored error. | ||
* | ||
* @return const E& Reference to the stored error. | ||
* @warning Behavior is undefined if the result holds a value. | ||
*/ | ||
const E& error() const { return error_; } |
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.
In include/msd/result.hpp, the value() and error() methods don't check the state of the result before returning values. This could lead to undefined behavior when accessing the wrong union member. Consider adding assertions or other safety mechanisms to prevent misuse.
private: | ||
union { | ||
T value_; | ||
E error_; | ||
}; | ||
bool has_error_{}; |
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.
In include/msd/result.hpp, using a union with non-trivial types without proper lifetime management could lead to undefined behavior. Consider implementing proper construction/destruction handling for the union members or using std::variant instead.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #85 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 3 4 +1
Lines 110 126 +16
Branches 6 9 +3
=========================================
+ Hits 110 126 +16 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
union { | ||
T value_; | ||
E error_; | ||
}; | ||
bool has_error_{}; |
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.
In include/msd/result.hpp, when E is a non-trivial type, the union could lead to undefined behavior without proper destruction. Consider adding a destructor that checks has_error_ and properly calls the destructor of the active member.
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.
In include/msd/channel.hpp, the wait_before_write method doesn't check if is_closed_ is true before waiting, which could lead to a thread waiting indefinitely when the channel is closed but full. Consider adding a check for is_closed_ in the wait condition.
A first successfully failed attempt at #31 |
No description provided.