Add a test to make sure we're doing the right thing for throwing exceptions from deferred functions. This is LWG issue #2186. No change to the library needed.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@204678 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -55,6 +55,12 @@ std::unique_ptr<int> f4(std::unique_ptr<int>&& p)
|
||||
return std::move(p);
|
||||
}
|
||||
|
||||
void f5(int i)
|
||||
{
|
||||
std::this_thread::sleep_for(ms(200));
|
||||
throw i;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
@@ -174,4 +180,17 @@ int main()
|
||||
Clock::time_point t1 = Clock::now();
|
||||
assert(t1-t0 < ms(100));
|
||||
}
|
||||
|
||||
{
|
||||
std::future<void> f = std::async(f5, 3);
|
||||
std::this_thread::sleep_for(ms(300));
|
||||
try { f.get(); assert (false); } catch ( int ex ) {}
|
||||
}
|
||||
|
||||
{
|
||||
std::future<void> f = std::async(std::launch::deferred, f5, 3);
|
||||
std::this_thread::sleep_for(ms(300));
|
||||
try { f.get(); assert (false); } catch ( int ex ) {}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user