|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r53794 - branches/release/boost/signals2/detail
From: fmhess_at_[hidden]
Date: 2009-06-11 14:53:07
Author: fmhess
Date: 2009-06-11 14:53:07 EDT (Thu, 11 Jun 2009)
New Revision: 53794
URL: http://svn.boost.org/trac/boost/changeset/53794
Log:
Merged [53779] from trunk.
Added:
branches/release/boost/signals2/detail/auto_buffer.hpp
- copied unchanged from r53779, /trunk/boost/signals2/detail/auto_buffer.hpp
Removed:
branches/release/boost/signals2/detail/stack_allocator.hpp
branches/release/boost/signals2/detail/stack_vector.hpp
Text files modified:
branches/release/boost/signals2/detail/slot_call_iterator.hpp | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
Modified: branches/release/boost/signals2/detail/slot_call_iterator.hpp
==============================================================================
--- branches/release/boost/signals2/detail/slot_call_iterator.hpp (original)
+++ branches/release/boost/signals2/detail/slot_call_iterator.hpp 2009-06-11 14:53:07 EDT (Thu, 11 Jun 2009)
@@ -19,7 +19,7 @@
#include <boost/scoped_ptr.hpp>
#include <boost/signals2/connection.hpp>
#include <boost/signals2/slot_base.hpp>
-#include <boost/signals2/detail/stack_vector.hpp>
+#include <boost/signals2/detail/auto_buffer.hpp>
#include <boost/signals2/detail/unique_lock.hpp>
#include <boost/weak_ptr.hpp>
@@ -34,7 +34,7 @@
f(f)
{}
optional<ResultType> result;
- typedef stack_vector<boost::shared_ptr<void>, 10> tracked_ptrs_type;
+ typedef auto_buffer<boost::shared_ptr<void>, store_n_objects<10> > tracked_ptrs_type;
tracked_ptrs_type tracked_ptrs;
Function f;
};
Deleted: branches/release/boost/signals2/detail/stack_allocator.hpp
==============================================================================
--- branches/release/boost/signals2/detail/stack_allocator.hpp 2009-06-11 14:53:07 EDT (Thu, 11 Jun 2009)
+++ (empty file)
@@ -1,112 +0,0 @@
-/*
- An allocator which first allocates from the stack, before falling
- back on usual std::allocator behavior. Used by signals2 to
- optimize the vector of tracked shared_ptr created during signal
- invocation.
-
- Example usage:
-
- static const std::size_t n = 10;
- stack_storage<T, n> storage;
- stack_allocator<T, n> a(&storage);
- std::vector<T, stack_allocator<T, n> > v(a);
-
-*/
-// Copyright Frank Mori Hess 2008.
-// Distributed under the Boost Software License, Version
-// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-// See http://www.boost.org/libs/signals2 for library home page.
-
-#ifndef BOOST_SIGNALS2_STACK_ALLOCATOR_HPP
-#define BOOST_SIGNALS2_STACK_ALLOCATOR_HPP
-
-#include <memory>
-#include <boost/noncopyable.hpp>
-#include <boost/type_traits/aligned_storage.hpp>
-#include <boost/type_traits/alignment_of.hpp>
-
-namespace boost
-{
- namespace signals2
- {
- namespace detail
- {
- template<typename T, std::size_t n_stack_elements>
- class stack_storage: public boost::noncopyable
- {
- public:
- typedef typename boost::aligned_storage<sizeof(T), boost::alignment_of<T>::value>::type storage_type;
- stack_storage(): is_reserved(false)
- {
- }
- storage_type array[n_stack_elements];
- bool is_reserved;
- };
- template<typename T, std::size_t n_stack_elements>
- class stack_allocator: public std::allocator<T>
- {
- typedef std::allocator<T> base_class;
- public:
- template<typename U>
- struct rebind
- {
- typedef stack_allocator<U, n_stack_elements> other;
- };
- stack_allocator(stack_storage<T, n_stack_elements> *storage = 0):
- _storage(storage)
- {
- }
- template<typename U, std::size_t n>
- stack_allocator(const stack_allocator<U, n> & other):
- _storage(0)
- {}
- typename base_class::pointer allocate(typename base_class::size_type n_elements,
- std::allocator<void>::const_pointer hint = 0)
- {
- if(_storage && _storage->is_reserved == false &&
- n_elements <= n_stack_elements)
- {
- _storage->is_reserved = true;
- return reinterpret_cast<typename base_class::pointer>(&_storage->array[0]);
- }
- return base_class::allocate(n_elements, hint);
- }
- void deallocate(typename base_class::pointer p, typename base_class::size_type n)
- {
- if(_storage &&
- p == reinterpret_cast<typename base_class::pointer>(&_storage->array[0]))
- {
- _storage->is_reserved = false;
- }else
- {
- base_class::deallocate(p, n);
- }
- }
- bool operator==(const stack_allocator &other)
- {
- return _storage == other._storage;
- }
- bool operator!=(const stack_allocator &other)
- {
- return _storage != other._storage;
- }
- template<typename U, std::size_t n>
- bool operator==(const stack_allocator<U, n> &other)
- {
- return _storage == 0 && other._storage == 0;
- }
- template<typename U, std::size_t n>
- bool operator!=(const stack_allocator<U, n> &other)
- {
- return _storage != 0 || other._storage != 0;
- }
- private:
- stack_storage<T, n_stack_elements> *_storage;
- };
- } // namespace detail
- } // namespace signals2
-} // namespace boost
-
-#endif // BOOST_SIGNALS2_STACK_ALLOCATOR_HPP
Deleted: branches/release/boost/signals2/detail/stack_vector.hpp
==============================================================================
--- branches/release/boost/signals2/detail/stack_vector.hpp 2009-06-11 14:53:07 EDT (Thu, 11 Jun 2009)
+++ (empty file)
@@ -1,48 +0,0 @@
-/*
- A non-copyable vector which first allocates from the stack, before falling
- back on usual std::allocator behavior.
-
-*/
-// Copyright Frank Mori Hess 2008.
-// Distributed under the Boost Software License, Version
-// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-// See http://www.boost.org/libs/signals2 for library home page.
-
-#ifndef BOOST_SIGNALS2_STACK_VECTOR_HPP
-#define BOOST_SIGNALS2_STACK_VECTOR_HPP
-
-#include <boost/noncopyable.hpp>
-#include <boost/signals2/detail/stack_allocator.hpp>
-#include <vector>
-
-namespace boost
-{
- namespace signals2
- {
- namespace detail
- {
- template<typename T, std::size_t NumStackElements>
- class stack_vector:
- public std::vector<T, stack_allocator<T, NumStackElements> >,
- public boost::noncopyable
- {
- typedef std::vector<T, stack_allocator<T, NumStackElements> > base_vector_type;
- public:
- static const std::size_t num_stack_elements = NumStackElements;
- stack_vector(): base_vector_type(stack_allocator<T, num_stack_elements>(&_storage))
- {
- base_vector_type::reserve(num_stack_elements);
- }
- private:
- stack_storage<T, num_stack_elements> _storage;
- };
- template<typename T, std::size_t NumStackElements>
- const std::size_t stack_vector<T, NumStackElements>::num_stack_elements;
-
- } // namespace detail
- } // namespace signals2
-} // namespace boost
-
-#endif // BOOST_SIGNALS2_STACK_VECTOR_HPP
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