Skip to content

Commit

Permalink
Future wait() before get()
Browse files Browse the repository at this point in the history
  • Loading branch information
COM8 committed Feb 14, 2025
1 parent a6c8fca commit eba6332
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion include/cpr/async_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "cpr/response.h"

namespace cpr {
enum class [[nodiscard]] CancellationResult{failure, success, invalid_operation};
enum class [[nodiscard]] CancellationResult { failure, success, invalid_operation };

/**
* A class template intended to wrap results of async operations (instances of std::future<T>)
Expand Down Expand Up @@ -53,6 +53,8 @@ class AsyncWrapper {
if (!future.valid()) {
throw std::logic_error{"Calling AsyncWrapper::get when the associated future instance is invalid!"};
}
// The wait is required on macos else std::future::get() will return prematurely somehow even though the c++ standard says something else.
future.wait();
return future.get();
}

Expand Down

0 comments on commit eba6332

Please sign in to comment.