Skip to content

Conversation

@andreiavrammsd
Copy link
Owner

No description provided.

@ghost
Copy link

ghost commented Jun 18, 2025

Pull Request Revisions

RevisionDescription
r2
Channel batch write error handlingModified channel batch write logic to improve error handling and add type safety for write errors
r1
Added batch write support for channelsImplemented batch write functionality for channels with error handling, capacity checking, and a new result type for error management

✅ AI review completed for r2
Help React with emojis to give feedback on AI-generated reviews:
  • 👍 means the feedback was helpful and actionable
  • 👎 means the feedback was incorrect or unhelpful
💬 Replying to feedback with a comment helps us improve the system. Your input also contributes to shaping future interactions with the AI reviewer.

We'd love to hear from you—reach out anytime at [email protected].

Comment on lines +45 to +59
/**
* @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_; }
Copy link

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.

Comment on lines +61 to +66
private:
union {
T value_;
E error_;
};
bool has_error_{};
Copy link

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
Copy link

codecov bot commented Jun 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (ef127e6) to head (3c5f998).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines +62 to +66
union {
T value_;
E error_;
};
bool has_error_{};
Copy link

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.

Copy link

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.

@andreiavrammsd
Copy link
Owner Author

A first successfully failed attempt at #31

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.

1 participant