-
Notifications
You must be signed in to change notification settings - Fork 371
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
Fixed move semantics of DownloadAttempt #2963
Conversation
cccf902
to
52ebc4e
Compare
52ebc4e
to
83be8ea
Compare
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.
LGTM, mostly have questions for details.
@@ -34,9 +34,11 @@ namespace mamba | |||
using on_success_callback = std::function<bool(DownloadSuccess)>; | |||
using on_failure_callback = std::function<bool(DownloadError)>; | |||
|
|||
explicit DownloadAttempt(const DownloadRequest& request); | |||
DownloadAttempt() = default; |
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.
I'm not totally sure but I think to link properly you need DownloadAttempt::DownloadAttempt()=default;
in the cpp (moving the definition in the cpp).
If you get no link issues in msvc, ignore this comment.
on_success_callback m_success_callback; | ||
on_failure_callback m_failure_callback; | ||
std::size_t m_retry_wait_seconds = std::size_t(0); | ||
std::unique_ptr<CompressionStream> p_stream = nullptr; |
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.
BTW can this be a normal member now? or an optional?
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.
It cannot because CompressionStream is a polymorphic type.
std::string m_last_modified; | ||
}; | ||
|
||
std::unique_ptr<Impl> p_impl = nullptr; |
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.
Note that it's already nullptr
by default.
DownloadError build_download_error(TransferData data) const; | ||
DownloadSuccess build_download_success(TransferData data) const; | ||
|
||
CURLHandle* p_handle = nullptr; |
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.
Isnt handle already a value/pointer? Do you need to point to it?
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.
With this change, the handle is now a member (value) of DownloadTracker, to avoid recreating it each time we build an attempt. But the attempt still needs it, thus this pointer.
{ | ||
m_retry_wait_seconds = std::size_t(0); | ||
return [impl = p_impl.get()](CURLMultiHandle& handle, CURLcode code) |
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.
If you find issues later with this lambda being called after impl
have been destroyed, consider using task_synchronizer to guarantee that this does not ever happen.
No description provided.