Skip to content

Commit 394d77a

Browse files
authored
Merge pull request #84 from Snapchat/lf/fix-empty-future-set
Fix calling `whenAll/whenAny` on empty future set
2 parents 3ff75be + 0080077 commit 394d77a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

support-lib/cpp/Future.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,10 @@ Future<void> combine(U&& futures, size_t c) {
330330
};
331331
auto context = std::make_shared<Context>(c);
332332
auto future = context->promise.getFuture();
333+
if (futures.empty()) {
334+
context->promise.setValue();
335+
return future;
336+
}
333337
for (auto& f: futures) {
334338
f.then([context] (auto f) {
335339
if (--(context->counter) == 0) {

0 commit comments

Comments
 (0)