summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/30_threads/async/sync.cc
diff options
context:
space:
mode:
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2013-11-21 14:26:12 +0000
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2013-11-21 14:26:12 +0000
commit3794d2f9c42acb8b9dcf036785e1e4a68b447b1d (patch)
treec008138542a2f30e26b4205a1f6f63e9e94368f0 /libstdc++-v3/testsuite/30_threads/async/sync.cc
parent677f8c6b8258c0b4c121f515063e8fab4ffa9c4a (diff)
parent7f8a3f4983825df08d845b7093beb81ecd7bb320 (diff)
downloadgcc-3794d2f9c42acb8b9dcf036785e1e4a68b447b1d.tar.gz
Merge with trunk.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/wide-int@205218 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite/30_threads/async/sync.cc')
-rw-r--r--libstdc++-v3/testsuite/30_threads/async/sync.cc24
1 files changed, 22 insertions, 2 deletions
diff --git a/libstdc++-v3/testsuite/30_threads/async/sync.cc b/libstdc++-v3/testsuite/30_threads/async/sync.cc
index e9b112ddf57..3e9cd34cd55 100644
--- a/libstdc++-v3/testsuite/30_threads/async/sync.cc
+++ b/libstdc++-v3/testsuite/30_threads/async/sync.cc
@@ -39,12 +39,32 @@ void test01()
using namespace std;
int a = 1;
- int b = 10;
- int c = 100;
+ int b = 1;
+ int c = 1;
future<int> f1 = async(launch::deferred, sum(), a, ref(b), cref(c));
+ a = 0;
+ b = 10;
+ c = 100;
+
+ const std::chrono::seconds delay(10);
+ const auto then = std::chrono::system_clock::now() + delay;
VERIFY( f1.valid() );
+ // timed waiting functions should return 'deferred' immediately
+ VERIFY( f1.wait_until(then) == std::future_status::deferred );
+ VERIFY( f1.wait_for(delay) == std::future_status::deferred );
+ VERIFY( std::chrono::system_clock::now() < then );
+
+ f1.wait();
+
+ VERIFY( f1.valid() );
+ // timed waiting functions should return 'ready' immediately
+ VERIFY( f1.wait_until(then) == std::future_status::ready );
+ VERIFY( f1.wait_for(delay) == std::future_status::ready );
+ VERIFY( std::chrono::system_clock::now() < then );
+
VERIFY( f1.get() == 111 );
+ VERIFY( !f1.valid() );
}
int main()