Skip to content

Commit

Permalink
Small cleanup
Browse files Browse the repository at this point in the history
We don't really need the return value.
  • Loading branch information
Vultraz committed Aug 2, 2019
1 parent 0f948f7 commit 6049851
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
15 changes: 4 additions & 11 deletions src/gui/dialogs/network_transmission.cpp
Expand Up @@ -44,17 +44,12 @@ network_transmission::pump_monitor::pump_monitor(connection_data*& connection)
, total_(0)
, stop_(false)
, poller_(std::async(std::launch::async, [this]() {
while(true) {
// connection_ will be null if we reset the ptr in the main thread before canceling the dialog
if(stop_) {
return false;
}

while(!stop_) {
// Check for updates
connection_->poll();

if(connection_->finished()) {
return true;
return;
}

completed_ = connection_->current();
Expand All @@ -73,7 +68,7 @@ void network_transmission::pump_monitor::process(events::pump_info&)
}

// Check if the thread is complete. If it is, loading is done.
if(poller_.wait_for(0ms) == std::future_status::ready && poller_.get()) {
if(poller_.wait_for(0ms) == std::future_status::ready) {
window_.get().set_retval(retval::OK);
return;
}
Expand Down Expand Up @@ -125,11 +120,9 @@ void network_transmission::post_show(window& /*window*/)

if(get_retval() == retval::CANCEL) {
// We need to wait for the current polling loop to conclude before exiting so we don't invalidate
// the pointer mid-loop, so signal that here. The thread should return false if connection_ is null.
// the pointer mid-loop, so signal that here.
pump_monitor_.stop_ = true;

pump_monitor_.poller_.wait();
assert(pump_monitor_.poller_.get() == false);

connection_->cancel();
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/dialogs/network_transmission.hpp
Expand Up @@ -68,7 +68,7 @@ class network_transmission : public modal_dialog

std::atomic_bool stop_;

std::future<bool> poller_;
std::future<void> poller_;
} pump_monitor_;

public:
Expand Down

0 comments on commit 6049851

Please sign in to comment.