|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r80460 - in trunk: boost/thread/detail libs/thread/test/sync/futures/packaged_task
From: vicente.botet_at_[hidden]
Date: 2012-09-09 08:41:32
Author: viboes
Date: 2012-09-09 08:41:31 EDT (Sun, 09 Sep 2012)
New Revision: 80460
URL: http://svn.boost.org/trac/boost/changeset/80460
Log:
Thread: Manage with statefull allocators and call destroy on the task object: #7349 and #7350
Text files modified:
trunk/boost/thread/detail/memory.hpp | 3 ++-
trunk/libs/thread/test/sync/futures/packaged_task/alloc_ctor_pass.cpp | 11 +++++++++++
2 files changed, 13 insertions(+), 1 deletions(-)
Modified: trunk/boost/thread/detail/memory.hpp
==============================================================================
--- trunk/boost/thread/detail/memory.hpp (original)
+++ trunk/boost/thread/detail/memory.hpp 2012-09-09 08:41:31 EDT (Sun, 09 Sep 2012)
@@ -33,7 +33,7 @@
typedef typename alloc_traits::pointer pointer;
typedef typename alloc_traits::size_type size_type;
private:
- _Alloc& alloc_;
+ _Alloc alloc_;
size_type s_;
public:
allocator_destructor(_Alloc& a, size_type s)BOOST_NOEXCEPT
@@ -41,6 +41,7 @@
{}
void operator()(pointer p)BOOST_NOEXCEPT
{
+ alloc_traits::destroy(alloc_, p);
alloc_traits::deallocate(alloc_, p, s_);
}
};
Modified: trunk/libs/thread/test/sync/futures/packaged_task/alloc_ctor_pass.cpp
==============================================================================
--- trunk/libs/thread/test/sync/futures/packaged_task/alloc_ctor_pass.cpp (original)
+++ trunk/libs/thread/test/sync/futures/packaged_task/alloc_ctor_pass.cpp 2012-09-09 08:41:31 EDT (Sun, 09 Sep 2012)
@@ -44,20 +44,27 @@
BOOST_THREAD_COPYABLE_AND_MOVABLE(A)
static int n_moves;
static int n_copies;
+ static int n_instances;
+ static int n_destroy;
explicit A(long i) : data_(i)
{
+ ++n_instances;
}
A(BOOST_THREAD_RV_REF(A) a) : data_(BOOST_THREAD_RV(a).data_)
{
+ ++n_instances;
++n_moves; BOOST_THREAD_RV(a).data_ = -1;
}
A(const A& a) : data_(a.data_)
{
+ ++n_instances;
++n_copies;
}
~A()
{
+ --n_instances;
+ ++n_destroy;
}
long operator()() const
@@ -68,6 +75,8 @@
int A::n_moves = 0;
int A::n_copies = 0;
+int A::n_instances = 0;
+int A::n_destroy = 0;
int main()
{
@@ -83,6 +92,8 @@
}
BOOST_TEST(A::n_copies == 0);
BOOST_TEST(A::n_moves > 0);
+ BOOST_TEST(A::n_instances == 0);
+ BOOST_TEST(A::n_destroy > 0);
BOOST_TEST(test_alloc_base::count == 0);
A::n_copies = 0;
A::n_copies = 0;
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk