Beispiel #1
0
   template<class U>
   propagation_test_allocator(const propagation_test_allocator
                                       < U
                                       , PropagateOnContCopyAssign
                                       , PropagateOnContMoveAssign
                                       , PropagateOnContSwap
                                       , CopyOnPropagateOnContSwap> &x)
      : id_(x.id_)
      , ctr_copies_(x.ctr_copies_+1)
      , ctr_moves_(0)
      , assign_copies_(0)
      , assign_moves_(0)
      , swaps_(0)
   {}

   propagation_test_allocator(BOOST_RV_REF(propagation_test_allocator) x)
      : id_(x.id_)
      , ctr_copies_(x.ctr_copies_)
      , ctr_moves_(x.ctr_moves_ + 1)
      , assign_copies_(x.assign_copies_)
      , assign_moves_(x.assign_moves_)
      , swaps_(x.swaps_)
   {}

   propagation_test_allocator &operator=(BOOST_COPY_ASSIGN_REF(propagation_test_allocator) x)
   {
      id_ = x.id_;
      ctr_copies_ = x.ctr_copies_;
      ctr_moves_ = x.ctr_moves_;
      assign_copies_ = x.assign_copies_+1;
      assign_moves_ = x.assign_moves_;
   template<class MemoryMappable>
   mapped_region(const MemoryMappable& mapping
                ,mode_t mode
                ,offset_t offset = 0
                ,std::size_t size = 0
                ,const void *address = 0
                ,map_options_t map_options = default_map_options);

   //!Default constructor. Address will be 0 (nullptr).
   //!Size will be 0.
   //!Does not throw
   mapped_region();

   //!Move constructor. *this will be constructed taking ownership of "other"'s
   //!region and "other" will be left in default constructor state.
   mapped_region(BOOST_RV_REF(mapped_region) other)
   #if defined (BOOST_INTERPROCESS_WINDOWS)
   :  m_base(0), m_size(0)
   ,  m_page_offset(0)
   ,  m_mode(read_only)
   ,  m_file_or_mapping_hnd(ipcdetail::invalid_file())
   #else
   :  m_base(0), m_size(0), m_page_offset(0), m_mode(read_only), m_is_xsi(false)
   #endif
   {  this->swap(other);   }

   //!Destroys the mapped region.
   //!Does not throw
   ~mapped_region();

   //!Move assignment. If *this owns a memory mapped region, it will be
Beispiel #3
0
        // run all callbacks attached to the exit event for this thread
        run_thread_exit_callbacks();
        return threads::terminated;
    }

    thread::id thread::get_id() const BOOST_NOEXCEPT
    {
        return id(native_handle());
    }

    std::size_t thread::hardware_concurrency() BOOST_NOEXCEPT
    {
        return hpx::threads::hardware_concurrency();
    }

    void thread::start_thread(BOOST_RV_REF(HPX_STD_FUNCTION<void()>) func)
    {
        threads::thread_init_data data(
            HPX_STD_BIND(&thread::thread_function_nullary, boost::move(func)),
            "thread::thread_function_nullary");

        error_code ec(lightweight);
        threads::thread_id_type ident = hpx::get_runtime().get_thread_manager().
            register_thread(data, threads::suspended, true, ec);
        if (ec) {
            HPX_THROW_EXCEPTION(thread_resource_error, "thread::start_thread",
                "Could not create thread");
            return;
        }

        // inform ourselves if the thread function exits
Beispiel #4
0
   {}
#endif

   //! <b>Effects</b>: Copy constructs a set.
   //!
   //! <b>Complexity</b>: Linear in x.size().
   set(const set& x)
      : base_t(static_cast<const base_t&>(x))
   {}

   //! <b>Effects</b>: Move constructs a set. Constructs *this using x's resources.
   //!
   //! <b>Complexity</b>: Constant.
   //!
   //! <b>Postcondition</b>: x is emptied.
   set(BOOST_RV_REF(set) x)
      : base_t(BOOST_MOVE_BASE(base_t, x))
   {}

   //! <b>Effects</b>: Copy constructs a set using the specified allocator.
   //!
   //! <b>Complexity</b>: Linear in x.size().
   set(const set& x, const allocator_type &a)
      : base_t(static_cast<const base_t&>(x), a)
   {}

   //! <b>Effects</b>: Move constructs a set using the specified allocator.
   //!                 Constructs *this using x's resources.
   //!
   //! <b>Complexity</b>: Constant if a == x.get_allocator(), linear otherwise.
   set(BOOST_RV_REF(set) x, const allocator_type &a)
    {
      x.tag_ = -1;
      ++moves;
      trace_op("Move construct");
    }

    count_copies& operator=(
      BOOST_COPY_ASSIGN_REF(count_copies) p) // Copy assignment
    {
      tag_ = p.tag_;
      ++copies;
      trace_op("Copy assign");
      return *this;
    }

    count_copies& operator=(BOOST_RV_REF(count_copies) p) // Move assignment
    {
      tag_ = p.tag_;
      ++moves;
      trace_op("Move assign");
      return *this;
    }

    ~count_copies() { trace_op("Destruct"); }

    void trace_op(char const* str)
    {
      BOOST_LIGHTWEIGHT_TEST_OSTREAM << str << ": " << tag_ << " (#" << id_
                                     << ")" << std::endl;
    }
Beispiel #6
0
   //!Tries to create a file with name "name" and mode "mode", with the
   //!access mode "mode". If the file previously exists, it tries to open it with mode "mode".
   //!Otherwise throws an error.
   file_wrapper(open_or_create_t, const char *name, mode_t mode, const permissions &perm  = permissions())
   {  this->priv_open_or_create(ipcdetail::DoOpenOrCreate, name, mode, perm);  }

   //!Tries to open a file with name "name", with the access mode "mode".
   //!If the file does not previously exist, it throws an error.
   file_wrapper(open_only_t, const char *name, mode_t mode)
   {  this->priv_open_or_create(ipcdetail::DoOpen, name, mode, permissions());  }

   //!Moves the ownership of "moved"'s file to *this.
   //!After the call, "moved" does not represent any file.
   //!Does not throw
   file_wrapper(BOOST_RV_REF(file_wrapper) moved)
      :  m_handle(file_handle_t(ipcdetail::invalid_file()))
   {  this->swap(moved);   }

   //!Moves the ownership of "moved"'s file to *this.
   //!After the call, "moved" does not represent any file.
   //!Does not throw
   file_wrapper &operator=(BOOST_RV_REF(file_wrapper) moved)
   {
      file_wrapper tmp(boost::move(moved));
      this->swap(tmp);
      return *this;
   }

   //!Swaps to file_wrappers.
   //!Does not throw
Beispiel #7
0
        //       alloc must meet the requirements of Allocator
        typedef detail::shared_state_object< R, Allocator >  object_t;
        typename object_t::allocator_t a( alloc);
        future_ = ptr_t(
                      // placement new
                      ::new( a.allocate( 1) ) object_t( a) );
    }

    ~promise()
    {
        //TODO: abandon ownership if any
        if ( future_)
            future_->owner_destroyed();
    }

promise( BOOST_RV_REF( promise) other) BOOST_NOEXCEPT :
    obtained_( false),
               future_()
    {
        //TODO: take over ownership
        //      other is valid before but in
        //      undefined state afterwards
        swap( other);
    }

    promise & operator=( BOOST_RV_REF( promise) other) BOOST_NOEXCEPT
    {
        //TODO: take over ownership
        //      other is valid before but in
        //      undefined state afterwards
        promise tmp( boost::move( other) );
Beispiel #8
0
   //! @copydoc ::boost::intrusive::splaytree::splaytree(const value_compare &,const value_traits &)
   explicit splay_set_impl( const value_compare &cmp = value_compare()
                    , const value_traits &v_traits = value_traits())
      :  tree_type(cmp, v_traits)
   {}

   //! @copydoc ::boost::intrusive::splaytree::splaytree(bool,Iterator,Iterator,const value_compare &,const value_traits &)
   template<class Iterator>
   splay_set_impl( Iterator b, Iterator e
           , const value_compare &cmp = value_compare()
           , const value_traits &v_traits = value_traits())
      : tree_type(true, b, e, cmp, v_traits)
   {}

   //! @copydoc ::boost::intrusive::splaytree::splaytree(splaytree &&)
   splay_set_impl(BOOST_RV_REF(splay_set_impl) x)
      :  tree_type(::boost::move(static_cast<tree_type&>(x)))
   {}

   //! @copydoc ::boost::intrusive::splaytree::operator=(splaytree &&)
   splay_set_impl& operator=(BOOST_RV_REF(splay_set_impl) x)
   {  return static_cast<splay_set_impl&>(tree_type::operator=(::boost::move(static_cast<tree_type&>(x)))); }

   #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
   //! @copydoc ::boost::intrusive::splaytree::~splaytree()
   ~splay_set_impl();

   //! @copydoc ::boost::intrusive::splaytree::begin()
   iterator begin();

   //! @copydoc ::boost::intrusive::splaytree::begin()const
//#define BOOST_THREAD_QUEUE_DEPRECATE_OLD

#include <boost/thread/concurrent_queues/sync_queue.hpp>
#include <boost/thread/concurrent_queues/queue_adaptor.hpp>
#include <boost/thread/concurrent_queues/queue_views.hpp>

#include <boost/detail/lightweight_test.hpp>
#include <boost/static_assert.hpp>

class non_copyable
{
  int val;
public:
  BOOST_THREAD_MOVABLE_ONLY(non_copyable)
  non_copyable(int v) : val(v){}
  non_copyable(BOOST_RV_REF(non_copyable) x): val(x.val) {}
  non_copyable& operator=(BOOST_RV_REF(non_copyable) x) { val=x.val; return *this; }
  bool operator==(non_copyable const& x) const {return val==x.val;}
  template <typename OSTREAM>
  friend OSTREAM& operator <<(OSTREAM& os, non_copyable const&x )
  {
    os << x.val;
    return os;
  }

};

#if defined  BOOST_NO_CXX11_RVALUE_REFERENCES
BOOST_STATIC_ASSERT( ! boost::is_copy_constructible<non_copyable>::value );
BOOST_STATIC_ASSERT( boost::has_move_emulation_enabled<non_copyable>::value );
#endif
            order(OrderT const& that) : OrderT(that) {}

            result_type operator() (enqueued_record const& left, enqueued_record const& right) const
            {
                // std::priority_queue requires ordering with semantics of std::greater, so we swap arguments
                return OrderT::operator() (right.m_record, left.m_record);
            }
        };

        boost::log::aux::timestamp m_timestamp;
        record_view m_record;

        enqueued_record(enqueued_record const& that) : m_timestamp(that.m_timestamp), m_record(that.m_record)
        {
        }
        enqueued_record(BOOST_RV_REF(enqueued_record) that) :
            m_timestamp(that.m_timestamp),
            m_record(boost::move(that.m_record))
        {
        }
        explicit enqueued_record(record_view const& rec) :
            m_timestamp(boost::log::aux::get_timestamp()),
            m_record(rec)
        {
        }
        enqueued_record& operator= (BOOST_COPY_ASSIGN_REF(enqueued_record) that)
        {
            m_timestamp = that.m_timestamp;
            m_record = that.m_record;
            return *this;
        }
   //!Tries to create a shared memory object with name "name" and mode "mode", with the
   //!access mode "mode". If the file previously exists, it tries to open it with mode "mode".
   //!Otherwise throws an error.
   shared_memory_object(open_or_create_t, const char *name, mode_t mode, const permissions &perm = permissions())
   {  this->priv_open_or_create(ipcdetail::DoOpenOrCreate, name, mode, perm);  }

   //!Tries to open a shared memory object with name "name", with the access mode "mode".
   //!If the file does not previously exist, it throws an error.
   shared_memory_object(open_only_t, const char *name, mode_t mode)
   {  this->priv_open_or_create(ipcdetail::DoOpen, name, mode, permissions());  }

   //!Moves the ownership of "moved"'s shared memory object to *this.
   //!After the call, "moved" does not represent any shared memory object.
   //!Does not throw
   shared_memory_object(BOOST_RV_REF(shared_memory_object) moved)
      :  m_handle(file_handle_t(ipcdetail::invalid_file()))
   {  this->swap(moved);   }

   //!Moves the ownership of "moved"'s shared memory to *this.
   //!After the call, "moved" does not represent any shared memory.
   //!Does not throw
   shared_memory_object &operator=(BOOST_RV_REF(shared_memory_object) moved)
   { 
      shared_memory_object tmp(lslboost::move(moved));
      this->swap(tmp);
      return *this; 
   }

   //!Swaps the shared_memory_objects. Does not throw
   void swap(shared_memory_object &moved);
Beispiel #12
0
#include <vector>

///////////////////////////////////////////////////////////////////////////////
namespace hpx
{
    /// The function \a when_any is a non-deterministic choice operator. It
    /// OR-composes all future objects stored in the given vector and returns
    /// a new future object representing the first future from that list which
    /// finishes execution.
    ///
    /// \return   The returned future holds the same list of futures as has
    ///           been passed to when_any.

    template <typename R>
    lcos::future<std::vector<lcos::future<R> > >
    when_any(BOOST_RV_REF(HPX_UTIL_STRIP((
        std::vector<lcos::future<R> >))) lazy_values,
        error_code& ec = throws)
    {
        typedef std::vector<lcos::future<R> > result_type;

        if (lazy_values.empty())
            return lcos::make_ready_future(result_type());

        return when_n(1, lazy_values, ec);
    }

    template <typename R>
    lcos::future<std::vector<lcos::future<R> > > //-V659
    when_any(std::vector<lcos::future<R> > const& lazy_values,
        error_code& ec = throws)
    {
   {  return *static_cast<node*>(static_cast<void*>(container_detail::to_raw_pointer(p))); }

   BOOST_MOVABLE_BUT_NOT_COPYABLE(basic_multiallocation_chain)

   public:


   typedef VoidPointer  void_pointer;
   typedef typename slist_impl_t::iterator iterator;
   typedef typename slist_impl_t::size_type size_type;

   basic_multiallocation_chain()
      :  slist_impl_()
   {}

   basic_multiallocation_chain(BOOST_RV_REF(basic_multiallocation_chain) other)
      :  slist_impl_()
   {  slist_impl_.swap(other.slist_impl_); }

   basic_multiallocation_chain& operator=(BOOST_RV_REF(basic_multiallocation_chain) other)
   {
      basic_multiallocation_chain tmp(lslboost::move(other));
      this->swap(tmp);
      return *this;
   }

   bool empty() const
   {  return slist_impl_.empty(); }

   size_type size() const
   {  return slist_impl_.size();  }
Beispiel #14
0
   BOOST_MOVABLE_BUT_NOT_COPYABLE(scoped_deallocator)

   public:

   pointer     m_ptr;
   A&  m_alloc;

   scoped_deallocator(pointer p, A& a)
      : m_ptr(p), m_alloc(a)
   {}

   ~scoped_deallocator()
   {  if (m_ptr)priv_deallocate(alloc_version());  }

   scoped_deallocator(BOOST_RV_REF(scoped_deallocator) o)
      :  m_ptr(o.m_ptr), m_alloc(o.m_alloc)
   {  o.release();  }

   pointer get() const
   {  return m_ptr;  }

   void set(const pointer &p)
   {  m_ptr = p;  }

   void release()
   {  m_ptr = 0; }
};

template <class Allocator>
struct null_scoped_deallocator
Beispiel #15
0
    //! Sink pointer type
    typedef weak_ptr< sinks::sink > sink_ptr;
    //! Iterator range with pointers to the accepting sinks
    typedef iterator_range< sink_ptr* > sink_list;

private:
    //! Number of sinks accepting the record
    uint32_t m_accepting_sink_count;
    //! Maximum number of sinks accepting the record
    const uint32_t m_accepting_sink_capacity;
    //! The flag indicates that the record has to be detached from the current thread
    bool m_detach_from_thread_needed;

private:
    //! Initializing constructor
    private_data(BOOST_RV_REF(attribute_value_set) values, uint32_t capacity) :
        public_data(boost::move(values)),
        m_accepting_sink_count(0),
        m_accepting_sink_capacity(capacity),
        m_detach_from_thread_needed(false)
    {
    }

public:
    //! Creates the object with the specified capacity
    static private_data* create(BOOST_RV_REF(attribute_value_set) values, uint32_t capacity)
    {
        private_data* p = reinterpret_cast< private_data* >(stateless_allocator().allocate
        (
            sizeof(private_data) +
            boost::log::aux::alignment_gap_between< private_data, sink_ptr >::value +
Beispiel #16
0
namespace hpx { namespace util { namespace detail
{
    template <typename F>
    class protected_bind
    {
    public:
        typedef typename F::result_type result_type;

        // copy constructor
        protected_bind(protected_bind const& other)
          : f_(other.f_)
        {
        }

        // move constructor
        protected_bind(BOOST_RV_REF(protected_bind) other)
          : f_(boost::move(other.f_))
        {
        }

        template <typename FF>
        explicit protected_bind(BOOST_FWD_REF(FF) f)
          : f_(boost::forward<FF>(f))
        {}

        protected_bind& operator=(BOOST_COPY_ASSIGN_REF(protected_bind) rhs)
        {
            if (this != &rhs)
                f_ = rhs.f_;
            return *this;
        }
Beispiel #17
0
   //!Default constructor.
   //!Represents an empty xsi_named_mutex.
   xsi_named_mutex();

   //!Tries to create a new XSI-based named mutex with a key obtained from a call to ftok (with path
   //!"path" and id "id"), and permissions "perm".
   //!If the named mutex previously exists, it tries to open it.
   //!Otherwise throws an error.
   xsi_named_mutex(open_or_create_t, const char *path, boost::uint8_t id, int perm = 0666)
   {  this->priv_open_or_create(ipcdetail::DoOpenOrCreate, path, id, perm);  }

   //!Moves the ownership of "moved"'s named mutex to *this. 
   //!After the call, "moved" does not represent any named mutex 
   //!Does not throw
   xsi_named_mutex(BOOST_RV_REF(xsi_named_mutex) moved)
   {  this->swap(moved);   }

   //!Moves the ownership of "moved"'s named mutex to *this.
   //!After the call, "moved" does not represent any named mutex. 
   //!Does not throw
   xsi_named_mutex &operator=(BOOST_RV_REF(xsi_named_mutex) moved)
   {  
      xsi_named_mutex tmp(boost::interprocess::move(moved));
      this->swap(tmp);
      return *this;  
   }

   //!Swaps two xsi_named_mutex. Does not throw
   void swap(xsi_named_mutex &other);
Beispiel #18
0
            completed_callback_type;

        // This is the component id. Every component needs to have an embedded
        // enumerator 'value' which is used by the generic action implementation
        // to associate this component with a given action.
        enum { value = components::component_promise };

        promise()
          : back_ptr_(0)
        {}

        promise(completed_callback_type const& data_sink)
          : future_data_type(data_sink), back_ptr_(0)
        {}

        promise(BOOST_RV_REF(completed_callback_type) data_sink)
          : future_data_type(boost::move(data_sink)), back_ptr_(0)
        {}

        // The implementation of the component is responsible for deleting the
        // actual managed component object
        ~promise()
        {
            this->finalize();
            delete back_ptr_;
        }

        // helper functions for setting data (if successful) or the error (if
        // non-successful)
        template <typename T>
        void set_local_data(BOOST_FWD_REF(T) result)
Beispiel #19
0
   //! @copydoc ::boost::intrusive::bstree::bstree(bool,Iterator,Iterator,const value_compare &,const value_traits &)
   template<class Iterator>
   splaytree_impl( bool unique, Iterator b, Iterator e
              , const value_compare &cmp     = value_compare()
              , const value_traits &v_traits = value_traits())
      : tree_type(cmp, v_traits)
   {
      if(unique)
         this->insert_unique(b, e);
      else
         this->insert_equal(b, e);
   }

   //! @copydoc ::boost::intrusive::bstree::bstree(bstree &&)
   splaytree_impl(BOOST_RV_REF(splaytree_impl) x)
      :  tree_type(BOOST_MOVE_BASE(tree_type, x))
   {}

   //! @copydoc ::boost::intrusive::bstree::operator=(bstree &&)
   splaytree_impl& operator=(BOOST_RV_REF(splaytree_impl) x)
   {  return static_cast<splaytree_impl&>(tree_type::operator=(BOOST_MOVE_BASE(tree_type, x))); }

   #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
   //! @copydoc ::boost::intrusive::bstree::~bstree()
   ~splaytree_impl();

   //! @copydoc ::boost::intrusive::bstree::begin()
   iterator begin();

   //! @copydoc ::boost::intrusive::bstree::begin()const
Beispiel #20
0
            BOOST_FWD_REF(Functor) f
          , typename ::boost::disable_if<
                typename boost::is_same<
                    function
                  , typename util::decay<Functor>::type
                >::type
            >::type * = 0
        )
            : base_type(boost::forward<Functor>(f))
        {}

        function(function const & other)
            : base_type(static_cast<base_type const &>(other))
        {}

        function(BOOST_RV_REF(function) other)
            : base_type(boost::move(static_cast<BOOST_RV_REF(base_type)>(other)))
        {}

        function& operator=(BOOST_COPY_ASSIGN_REF(function) t)
        {
            this->base_type::operator=(t);
            return *this;
        }

        function& operator=(BOOST_RV_REF(function) t)
        {
            this->base_type::operator=(boost::move(static_cast<BOOST_RV_REF(base_type)>(t)));
            return *this;
        }
Beispiel #21
0
    context_object( Fn && fn, Allocator const& alloc, std::size_t size, flag_unwind_t do_unwind, typename context_base::ptr_t nxt) :
        fn_t( static_cast< Fn && >( fn) ), alloc_t( alloc),
        context_base( alloc_t::member, size, do_unwind, nxt)
    {}
#else
    context_object( Fn fn, Allocator const& alloc, std::size_t size, flag_unwind_t do_unwind, flag_return_t do_return) :
        fn_t( fn), alloc_t( alloc),
        context_base( alloc_t::member, size, do_unwind, do_return)
    {}

    context_object( Fn fn, Allocator const& alloc, std::size_t size, flag_unwind_t do_unwind, typename context_base::ptr_t nxt) :
        fn_t( fn), alloc_t( alloc),
        context_base( alloc_t::member, size, do_unwind, nxt)
    {}

    context_object( BOOST_RV_REF( Fn) fn, Allocator const& alloc, std::size_t size, flag_unwind_t do_unwind, flag_return_t do_return) :
        fn_t( fn), alloc_t( alloc),
        context_base( alloc_t::member, size, do_unwind, do_return)
    {}

    context_object( BOOST_RV_REF( Fn) fn, Allocator const& alloc, std::size_t size, flag_unwind_t do_unwind, typename context_base::ptr_t nxt) :
        fn_t( fn), alloc_t( alloc),
        context_base( alloc_t::member, size, do_unwind, nxt)
    {}
#endif

	~context_object()
	{ cleanup( alloc_t::member); }

    void exec()
    { fn_t::member(); }
Beispiel #22
0
   //! @copydoc ::boost::intrusive::rbtree::rbtree(const key_compare &,const value_traits &)
   explicit set_impl( const key_compare &cmp = key_compare()
                    , const value_traits &v_traits = value_traits())
      :  tree_type(cmp, v_traits)
   {}

   //! @copydoc ::boost::intrusive::rbtree::rbtree(bool,Iterator,Iterator,const key_compare &,const value_traits &)
   template<class Iterator>
   set_impl( Iterator b, Iterator e
           , const key_compare &cmp = key_compare()
           , const value_traits &v_traits = value_traits())
      : tree_type(true, b, e, cmp, v_traits)
   {}

   //! @copydoc ::boost::intrusive::rbtree::rbtree(rbtree &&)
   set_impl(BOOST_RV_REF(set_impl) x)
      :  tree_type(BOOST_MOVE_BASE(tree_type, x))
   {}

   //! @copydoc ::boost::intrusive::rbtree::operator=(rbtree &&)
   set_impl& operator=(BOOST_RV_REF(set_impl) x)
   {  return static_cast<set_impl&>(tree_type::operator=(BOOST_MOVE_BASE(tree_type, x))); }

   #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
   //! @copydoc ::boost::intrusive::rbtree::~rbtree()
   ~set_impl();

   //! @copydoc ::boost::intrusive::rbtree::begin()
   iterator begin();

   //! @copydoc ::boost::intrusive::rbtree::begin()const
Beispiel #23
0
        ptr_ = new int( 0);
    }

    explicit movable_t( int x)
    {
        //std::cout << "ctor" << std::endl;
        ptr_ = new int( x);
    }

    movable_t( const movable_t& other)
    {
        //std::cout << "copy" << std::endl;
        ptr_ = new int( other.value());
    }

   movable_t( BOOST_RV_REF( movable_t) other) : ptr_( other.ptr_)
   {
        assert( ptr_);
        assert( other.ptr_);

        //std::cout << "move" << std::endl;
        other.ptr_ = 0;
   }

    ~movable_t()
    {
        //std::cout << "dtor" << std::endl;
        delete ptr_;
    }

    movable_t& operator=( BOOST_COPY_ASSIGN_REF( movable_t) other) // Copy assignment
            m_timestamp(that.m_timestamp),
            m_record(boost::move(that.m_record))
        {
        }
        explicit enqueued_record(record_type const& rec) :
            m_timestamp(boost::log::aux::get_timestamp()),
            m_record(rec)
        {
        }
        enqueued_record& operator= (BOOST_COPY_ASSIGN_REF(enqueued_record) that)
        {
            m_timestamp = that.m_timestamp;
            m_record = that.m_record;
            return *this;
        }
        enqueued_record& operator= (BOOST_RV_REF(enqueued_record) that)
        {
            m_timestamp = that.m_timestamp;
            m_record = boost::move(that.m_record);
            return *this;
        }
    };

    typedef std::priority_queue<
        enqueued_record,
        std::vector< enqueued_record >,
        typename enqueued_record::order
    > queue_type;

private:
    //! Ordering window duration, in milliseconds
                ipcdetail::DoOpen))
   {}

   //!Connects to a created shared memory and its segment manager.
   //!This can throw.
   basic_managed_shared_memory (open_only_t open_only, const char* name,
                                const void *addr = 0)
      : base_t()
      , base2_t(open_only, name, read_write, addr,
                create_open_func_t(get_this_pointer(),
                ipcdetail::DoOpen))
   {}

   //!Moves the ownership of "moved"'s managed memory to *this.
   //!Does not throw
   basic_managed_shared_memory(BOOST_RV_REF(basic_managed_shared_memory) moved)
   {
      basic_managed_shared_memory tmp;
      this->swap(moved);
      tmp.swap(moved);
   }

   //!Moves the ownership of "moved"'s managed memory to *this.
   //!Does not throw
   basic_managed_shared_memory &operator=(BOOST_RV_REF(basic_managed_shared_memory) moved)
   {
      basic_managed_shared_memory tmp(boost::move(moved));
      this->swap(tmp);
      return *this;
   }
Beispiel #26
0
     * @param ownMemory Set to false if the memory is only a reference and managed outside of this class
     * @param pitch Pitch in bytes (number of bytes in the lower dimensions)
     */
    HINLINE HostBuffer(Type* ptr, const math::Size_t<T_dim>& size, bool ownMemory, PitchType pitch = PitchType::create(0))
    {
        this->dataPointer = ptr;
        this->_size = size;
        if(T_dim >= 2)
            this->pitch[0] = (pitch[0]) ? pitch[0] : size.x() * sizeof(Type);
        if(T_dim == 3)
            this->pitch[1] = (pitch[1]) ? pitch[1] : this->pitch[0] * size.y();
        this->refCount = new int;
        *this->refCount = (ownMemory) ? 1 : 2;
    }
    HINLINE HostBuffer(const Base& base) : Base(base) {}
    HINLINE HostBuffer(BOOST_RV_REF(HostBuffer) obj): Base(boost::move(static_cast<Base&>(obj))) {}

    HINLINE HostBuffer&
    operator=(BOOST_RV_REF(HostBuffer) rhs)
    {
        Base::operator=(boost::move(static_cast<Base&>(rhs)));
        return *this;
    }

    template<typename DBuffer>
    HINLINE
    typename boost::enable_if<
		boost::is_same<typename DBuffer::memoryTag, allocator::tag::device>,
		HostBuffer&
		>::type
    operator=(const DBuffer& rhs)
                 mode_t mode,
                 const void *addr,
                 const ConstructFunc &construct_func,
                 const permissions &perm)
   {
      priv_open_or_create
         ( DoOpenOrCreate
         , id
         , size
         , mode
         , addr
         , perm
         , construct_func);
   }

   managed_open_or_create_impl(BOOST_RV_REF(managed_open_or_create_impl) moved)
   {  this->swap(moved);   }

   managed_open_or_create_impl &operator=(BOOST_RV_REF(managed_open_or_create_impl) moved)
   {
      managed_open_or_create_impl tmp(boost::move(moved));
      this->swap(tmp);
      return *this;
   }

   ~managed_open_or_create_impl()
   {}

   std::size_t get_user_size()  const
   {  return m_mapped_region.get_size() - ManagedOpenOrCreateUserOffset; }
Beispiel #28
0
struct poly_param_value_interface : core::poly_regular_interface {};

template <typename T>
struct poly_param_value_instance : core::optimized_storage_type<T, poly_param_value_interface>::type
{
private:

    BOOST_CONCEPT_ASSERT(( ParamValueConcept<T>));

public:

    typedef typename core::optimized_storage_type<T, poly_param_value_interface>::type base_type;

    poly_param_value_instance(const T& x) : base_type( x) {}

    poly_param_value_instance( BOOST_RV_REF( T) x) : base_type( x) {}

    RAMEN_POLY_INLINE_COPY_AND_ASSIGN( poly_param_value_instance, base_type)

    bool equals( const core::poly_regular_interface& x) const
    {
        return this->type_info() == x.type_info() &&
               this->get() == *static_cast<const T*>( x.cast());
    }
};

struct param_value : core::poly_base<poly_param_value_interface, poly_param_value_instance>
{
    typedef core::poly_base<poly_param_value_interface, poly_param_value_instance> base_type;

    param_value() : base_type( core::empty_t()) {}
Beispiel #29
0
   T1 first;
   T2 second;

   //Default constructor
   pair()
      : first(), second()
   {}

   //pair copy assignment
   pair(const pair& x)
      : first(x.first), second(x.second)
   {}

   //pair move constructor
   pair(BOOST_RV_REF(pair) p)
      : first(::lslboost::move(p.first)), second(::lslboost::move(p.second))
   {}

   template <class D, class S>
   pair(const pair<D, S> &p)
      : first(p.first), second(p.second)
   {}

   template <class D, class S>
   pair(BOOST_RV_REF_BEG pair<D, S> BOOST_RV_REF_END p)
      : first(::lslboost::move(p.first)), second(::lslboost::move(p.second))
   {}

   //pair from two values
   pair(const T1 &t1, const T2 &t2)
Beispiel #30
0
#else
            fs::path dll_path(dll_name);
#endif
            map_name = fs::basename(dll_path);
        }

        void load_library(error_code& ec = throws)
        {
            LoadLibrary(ec);
        }

        dll(std::string const& libname, std::string const& mapname)
        :   dll_name(libname), map_name(mapname), dll_handle(NULL)
        {}

        dll(BOOST_RV_REF(dll) rhs)
          : dll_name(boost::move(rhs.dll_name))
          , map_name(boost::move(rhs.map_name))
          , dll_handle(rhs.dll_handle)
        {
            rhs.dll_handle = NULL;
        }

        dll &operator=(BOOST_COPY_ASSIGN_REF(dll) rhs)
        {
            if (this != &rhs) {
            //  free any existing dll_handle
                FreeLibrary();

            //  load the library for this instance of the dll class
                dll_name = rhs.dll_name;