Skip to content

Commit 21215c3

Browse files
author
Alex Damian
authored
Merge pull request #146 from accelerated/promise-constructor
Added compile test for the Proimse constructor
2 parents 37ec276 + cd6d11a commit 21215c3

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

quantum/util/impl/quantum_generic_future_impl.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,15 @@ GenericFuture<T>::GenericFuture()
6363
{}
6464

6565
template <typename T>
66-
GenericFuture<T>::GenericFuture(const Promise<T>& p) :
67-
_context(local::context() ? p.getICoroFuture() : p.getIThreadFuture())
68-
{}
66+
GenericFuture<T>::GenericFuture(const Promise<T>& p)
67+
{
68+
if (local::context()) {
69+
_context = p.getICoroFuture();
70+
}
71+
else {
72+
_context = p.getIThreadFuture();
73+
}
74+
}
6975

7076
template <typename T>
7177
GenericFuture<T>::GenericFuture(ThreadContextPtr<T> f) :

tests/quantum_generic_future_tests.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ TEST(GenericFuture, TestCopyable)
8787
//create one future
8888
v.push_back(dispatcher.post([](VoidContextPtr)->int{ return 33; }));
8989

90+
//use Promise constructor
91+
v.push_back(Promise<int>{});
92+
9093
//copy it
9194
v.push_back(v.front());
9295

0 commit comments

Comments
 (0)