Skip to content

Commit eba6332

Browse files
committed
Future wait() before get()
1 parent a6c8fca commit eba6332

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

include/cpr/async_wrapper.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "cpr/response.h"
99

1010
namespace cpr {
11-
enum class [[nodiscard]] CancellationResult{failure, success, invalid_operation};
11+
enum class [[nodiscard]] CancellationResult { failure, success, invalid_operation };
1212

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

0 commit comments

Comments
 (0)