summaryrefslogtreecommitdiffstats
path: root/libcxx/test/thread
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2014-10-23 06:24:45 +0000
committerEric Fiselier <eric@efcs.ca>2014-10-23 06:24:45 +0000
commit83fb578e4e6f0a8c095f6e4ed0ccd7439a41c7cc (patch)
treeeeb3a3f631b8d2417a03e72799e0dab5c81ba60a /libcxx/test/thread
parent2ee0e9e6ee1dd2d86a2f4d4ea6bbfa5577ffe982 (diff)
downloadbcm5719-llvm-83fb578e4e6f0a8c095f6e4ed0ccd7439a41c7cc.tar.gz
bcm5719-llvm-83fb578e4e6f0a8c095f6e4ed0ccd7439a41c7cc.zip
Add support for "fancy" pointers to promise and packaged_task.
Summary: This patch is very closely related to D4859. Please see http://reviews.llvm.org/D4859 for more information. This patch adds support for "fancy" pointers and allocators to promise and packaged_task. The changes made to support this are exactly the same as in D4859. Test Plan: "fancy" pointer tests were added to each constructor affected by the change. Reviewers: danalbert, mclow.lists Reviewed By: mclow.lists Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4862 llvm-svn: 220471
Diffstat (limited to 'libcxx/test/thread')
-rw-r--r--libcxx/test/thread/futures/futures.promise/alloc_ctor.pass.cpp33
-rw-r--r--libcxx/test/thread/futures/futures.tas/futures.task.members/ctor_func_alloc.pass.cpp27
2 files changed, 60 insertions, 0 deletions
diff --git a/libcxx/test/thread/futures/futures.promise/alloc_ctor.pass.cpp b/libcxx/test/thread/futures/futures.promise/alloc_ctor.pass.cpp
index 3b473508346..70a4e00b0d6 100644
--- a/libcxx/test/thread/futures/futures.promise/alloc_ctor.pass.cpp
+++ b/libcxx/test/thread/futures/futures.promise/alloc_ctor.pass.cpp
@@ -20,6 +20,7 @@
#include <cassert>
#include "../test_allocator.h"
+#include "min_allocator.h"
int main()
{
@@ -48,4 +49,36 @@ int main()
assert(f.valid());
}
assert(test_alloc_base::count == 0);
+ // Test with a minimal allocator
+ {
+ std::promise<int> p(std::allocator_arg, bare_allocator<void>());
+ std::future<int> f = p.get_future();
+ assert(f.valid());
+ }
+ {
+ std::promise<int&> p(std::allocator_arg, bare_allocator<void>());
+ std::future<int&> f = p.get_future();
+ assert(f.valid());
+ }
+ {
+ std::promise<void> p(std::allocator_arg, bare_allocator<void>());
+ std::future<void> f = p.get_future();
+ assert(f.valid());
+ }
+ // Test with a minimal allocator that returns class-type pointers
+ {
+ std::promise<int> p(std::allocator_arg, min_allocator<void>());
+ std::future<int> f = p.get_future();
+ assert(f.valid());
+ }
+ {
+ std::promise<int&> p(std::allocator_arg, min_allocator<void>());
+ std::future<int&> f = p.get_future();
+ assert(f.valid());
+ }
+ {
+ std::promise<void> p(std::allocator_arg, min_allocator<void>());
+ std::future<void> f = p.get_future();
+ assert(f.valid());
+ }
}
diff --git a/libcxx/test/thread/futures/futures.tas/futures.task.members/ctor_func_alloc.pass.cpp b/libcxx/test/thread/futures/futures.tas/futures.task.members/ctor_func_alloc.pass.cpp
index 347c5cd399e..3aac2b26bfc 100644
--- a/libcxx/test/thread/futures/futures.tas/futures.task.members/ctor_func_alloc.pass.cpp
+++ b/libcxx/test/thread/futures/futures.tas/futures.task.members/ctor_func_alloc.pass.cpp
@@ -20,6 +20,7 @@
#include <cassert>
#include "../../test_allocator.h"
+#include "min_allocator.h"
class A
{
@@ -94,4 +95,30 @@ int main()
assert(f.get() == 4);
}
assert(test_alloc_base::count == 0);
+ A::n_copies = 0;
+ A::n_moves = 0;
+ {
+ std::packaged_task<double(int, char)> p(std::allocator_arg,
+ bare_allocator<void>(), A(5));
+ assert(p.valid());
+ std::future<double> f = p.get_future();
+ p(3, 'a');
+ assert(f.get() == 105.0);
+ assert(A::n_copies == 0);
+ assert(A::n_moves > 0);
+ }
+ A::n_copies = 0;
+ A::n_moves = 0;
+ {
+ std::packaged_task<double(int, char)> p(std::allocator_arg,
+ min_allocator<void>(), A(5));
+ assert(p.valid());
+ std::future<double> f = p.get_future();
+ p(3, 'a');
+ assert(f.get() == 105.0);
+ assert(A::n_copies == 0);
+ assert(A::n_moves > 0);
+ }
+ A::n_copies = 0;
+ A::n_moves = 0;
}
OpenPOWER on IntegriCloud