DriveHQ Start Menu
Cloud Drive Mapping
Folder Sync
Cloud Backup
True Drop Box
FTP/SFTP Hosting
Group Account
DriveHQ Start Menu
Online File Server
My Storage
|
Manage Shares
|
Publishes
|
Drop Boxes
|
Group Account
WebDAV Drive Mapping
Cloud Drive Home
|
WebDAV Guide
|
Drive Mapping Tool
|
Drive Mapping URL
Complete Data Backup
Backup Guide
|
Online Backup Tool
|
Cloud-to-Cloud Backup
FTP, Email & Web Service
FTP Home
|
FTP Hosting FAQ
|
Email Hosting
|
EmailManager
|
Web Hosting
Help & Resources
About
|
Enterprise Service
|
Partnership
|
Comparisons
|
Support
Quick Links
Security and Privacy
Download Software
Service Manual
Use Cases
Group Account
Online Help
Blog
Contact
Cloud Surveillance
Sign Up
Login
Features
Business Features
Online File Server
FTP Hosting
Cloud Drive Mapping
Cloud File Backup
Email Backup & Hosting
Cloud File Sharing
Folder Synchronization
Group Management
True Drop Box
Full-text Search
AD Integration/SSO
Mobile Access
IP Camera & DVR Solution
More...
Personal Features
Personal Cloud Drive
Backup All Devices
Mobile APPs
Personal Web Hosting
Sub-Account (for Kids)
Home/PC/Kids Monitoring
More...
Software
DriveHQ Drive Mapping Tool
DriveHQ FileManager
DriveHQ Online Backup
DriveHQ Mobile Apps
Pricing
Business Plans & Pricing
Personal Plans & Pricing
Price Comparison with Others
Feature Comparison with Others
Install Mobile App
Sign up
Creating account...
Invalid character in username! Only 0-9, a-z, A-Z, _, -, . allowed.
Username is required!
Invalid email address!
E-mail is required!
Password is required!
Password is invalid!
Password and confirmation do not match.
Confirm password is required!
I accept
Membership Agreement
Please read the Membership Agreement and check "I accept"!
Free Quick Sign-up
Sign-up Page
Log in
Signing in...
Username or e-mail address is required!
Password is required!
Keep me logged in
Quick Login
Forgot Password
Up
Upload
Download
Share
Publish
New Folder
New File
Copy
Cut
Delete
Paste
Rate
Upgrade
Rotate
Effect
Edit
Slide
History
////////////////////////////////////////////////////////////////////////////// // // (C) Copyright Ion Gaztanaga 2005-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/interprocess for documentation. // ////////////////////////////////////////////////////////////////////////////// #ifndef BOOST_INTERPROCESS_DETAIL_NODE_ALLOC_HPP_ #define BOOST_INTERPROCESS_DETAIL_NODE_ALLOC_HPP_ #if (defined _MSC_VER) && (_MSC_VER >= 1200) # pragma once #endif #include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
namespace boost { namespace interprocess { namespace detail { template
struct node_compare : private ValueCompare { typedef typename ValueCompare::key_type key_type; typedef typename ValueCompare::value_type value_type; typedef typename ValueCompare::key_of_value key_of_value; node_compare(const ValueCompare &pred) : ValueCompare(pred) {} ValueCompare &value_comp() { return static_cast
(*this); } ValueCompare &value_comp() const { return static_cast
(*this); } bool operator()(const Node &a, const Node &b) const { return ValueCompare::operator()(a.m_data, b.m_data); } }; template
struct node_alloc_holder { typedef node_alloc_holder
self_t; typedef typename A::value_type value_type; typedef typename ICont::value_type Node; typedef typename A::template rebind
::other NodeAlloc; typedef A ValAlloc; typedef typename NodeAlloc::pointer NodePtr; typedef detail::scoped_deallocator
Deallocator; typedef typename NodeAlloc::size_type size_type; typedef typename NodeAlloc::difference_type difference_type; typedef detail::integral_constant
allocator_v1; typedef detail::integral_constant
allocator_v2; typedef detail::integral_constant
::value> alloc_version; typedef typename ICont::iterator icont_iterator; typedef typename ICont::const_iterator icont_citerator; typedef allocator_destroyer
Destroyer; node_alloc_holder(const ValAlloc &a) : members_(a) {} node_alloc_holder(const node_alloc_holder &other) : members_(other.node_alloc()) {} #ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE node_alloc_holder(const detail::moved_object
&other) : members_(move(other.get().node_alloc())) { this->swap(other.get()); } #else node_alloc_holder(node_alloc_holder &&other) : members_(move(other.node_alloc())) { this->swap(other); } #endif template
node_alloc_holder(const ValAlloc &a, const Pred &c) : members_(a, typename ICont::value_compare(c)) {} #ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE template
node_alloc_holder(const detail::moved_object
&a, const Pred &c) : members_(a.get(), typename ICont::value_compare(c)) {} #else template
node_alloc_holder(ValAlloc &&a, const Pred &c) : members_(a, typename ICont::value_compare(c)) {} #endif template
node_alloc_holder(const node_alloc_holder &other, const Pred &c) : members_(other.node_alloc(), typename ICont::value_compare(c)) {} ~node_alloc_holder() {} size_type max_size() const { return this->node_alloc().max_size(); } NodePtr allocate_one() { return this->allocate_one(alloc_version()); } NodePtr allocate_one(allocator_v1) { return this->node_alloc().allocate(1); } NodePtr allocate_one(allocator_v2) { return this->node_alloc().allocate_one(); } void deallocate_one(NodePtr p) { return this->deallocate_one(p, alloc_version()); } void deallocate_one(NodePtr p, allocator_v1) { this->node_alloc().deallocate(p, 1); } void deallocate_one(NodePtr p, allocator_v2) { this->node_alloc().deallocate_one(p); } #ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE template
static void construct(const NodePtr &ptr, const Convertible &value) { new(detail::get_pointer(ptr)) Node(value); } #else template
static void construct(const NodePtr &ptr, Convertible &&value) { new(detail::get_pointer(ptr)) Node(forward
(value)); } #endif static void construct(const NodePtr &ptr) { new(detail::get_pointer(ptr)) Node(); } #ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE template
static void construct(const NodePtr &ptr, const detail::moved_object
> &value) { typedef typename Node::hook_type hook_type; typedef typename Node::value_type::first_type first_type; typedef typename Node::value_type::second_type second_type; Node *nodeptr = detail::get_pointer(ptr); //Hook constructor does not throw new(static_cast
(nodeptr))hook_type(); //Now construct pair members_holder value_type *valueptr = &nodeptr->m_data; new((void*)&valueptr->first) first_type(move(value.get().first)); BOOST_TRY{ new((void*)&valueptr->second) second_type(move(value.get().second)); } BOOST_CATCH(...){ valueptr->first.~first_type(); static_cast
(nodeptr)->~hook_type(); BOOST_RETHROW } BOOST_CATCH_END } #else template
static void construct(const NodePtr &ptr, std::pair
&&value) { typedef typename Node::hook_type hook_type; typedef typename Node::value_type::first_type first_type; typedef typename Node::value_type::second_type second_type; Node *nodeptr = detail::get_pointer(ptr); //Hook constructor does not throw new(static_cast
(nodeptr))hook_type(); //Now construct pair members_holder value_type *valueptr = &nodeptr->m_data; new((void*)&valueptr->first) first_type(move(value.first)); BOOST_TRY{ new((void*)&valueptr->second) second_type(move(value.second)); } BOOST_CATCH(...){ valueptr->first.~first_type(); static_cast
(nodeptr)->~hook_type(); BOOST_RETHROW } BOOST_CATCH_END } #endif static void destroy(const NodePtr &ptr) { detail::get_pointer(ptr)->~Node(); } #ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE template
NodePtr create_node(const Convertible& x) { NodePtr p = this->allocate_one(); Deallocator node_deallocator(p, this->node_alloc()); self_t::construct(p, x); node_deallocator.release(); return (p); } #else template
NodePtr create_node(Convertible &&x) { NodePtr p = this->allocate_one(); Deallocator node_deallocator(p, this->node_alloc()); self_t::construct(p, forward
(x)); node_deallocator.release(); return (p); } #endif template
NodePtr create_node_from_it(It it) { NodePtr p = this->allocate_one(); Deallocator node_deallocator(p, this->node_alloc()); ::boost::interprocess::construct_in_place(detail::get_pointer(p), it); node_deallocator.release(); return (p); } NodePtr create_node() { NodePtr p = this->allocate_one(); Deallocator node_deallocator(p, this->node_alloc()); self_t::construct(p); node_deallocator.release(); return (p); } void destroy_node(NodePtr node) { self_t::destroy(node); this->deallocate_one(node); } void swap(node_alloc_holder &x) { NodeAlloc& this_alloc = this->node_alloc(); NodeAlloc& other_alloc = x.node_alloc(); if (this_alloc != other_alloc){ detail::do_swap(this_alloc, other_alloc); } this->icont().swap(x.icont()); } template
FwdIterator allocate_many_and_construct (FwdIterator beg, difference_type n, Inserter inserter) { typedef typename NodeAlloc::multiallocation_iterator multiallocation_iterator; //Try to allocate memory in a single chunk multiallocation_iterator itbeg = this->node_alloc().allocate_individual(n), itend, itold; int constructed = 0; Node *p = 0; BOOST_TRY{ for(difference_type i = 0; i < n; ++i, ++beg, --constructed){ p = &*itbeg; ++itbeg; //This can throw boost::interprocess::construct_in_place(p, beg); ++constructed; //This can throw in some containers (predicate might throw) inserter(*p); } } BOOST_CATCH(...){ if(constructed){ this->destroy(p); } this->node_alloc().deallocate_many(itbeg); BOOST_RETHROW } BOOST_CATCH_END return beg; } void clear(allocator_v1) { this->icont().clear_and_dispose(Destroyer(this->node_alloc())); } void clear(allocator_v2) { allocator_multialloc_chain_node_deallocator
chain_holder(this->node_alloc()); this->icont().clear_and_dispose(chain_holder.get_chain_builder()); } icont_iterator erase_range(icont_iterator first, icont_iterator last, allocator_v1) { return this->icont().erase_and_dispose(first, last, Destroyer(this->node_alloc())); } icont_iterator erase_range(icont_iterator first, icont_iterator last, allocator_v2) { allocator_multialloc_chain_node_deallocator
chain_holder(this->node_alloc()); return this->icont().erase_and_dispose(first, last, chain_holder.get_chain_builder()); } template
size_type erase_key(const Key& k, const Comparator &comp, allocator_v1) { return this->icont().erase_and_dispose(k, comp, Destroyer(this->node_alloc())); } template
size_type erase_key(const Key& k, const Comparator &comp, allocator_v2) { allocator_multialloc_chain_node_deallocator
chain_holder(this->node_alloc()); return this->icont().erase_and_dispose(k, comp, chain_holder.get_chain_builder()); } protected: struct cloner { cloner(node_alloc_holder &holder) : m_holder(holder) {} NodePtr operator()(const Node &other) const { return m_holder.create_node(other.m_data); } node_alloc_holder &m_holder; }; struct destroyer { destroyer(node_alloc_holder &holder) : m_holder(holder) {} void operator()(NodePtr n) const { m_holder.destroy_node(n); } node_alloc_holder &m_holder; }; struct members_holder : public NodeAlloc { private: members_holder(const members_holder&); public: template
members_holder(const ConvertibleToAlloc &c2alloc) : NodeAlloc(c2alloc) {} template
members_holder(const ConvertibleToAlloc &c2alloc, const Pred &c) : NodeAlloc(c2alloc), m_icont(c) {} //The intrusive container ICont m_icont; } members_; ICont &non_const_icont() const { return const_cast
(this->members_.m_icont); } ICont &icont() { return this->members_.m_icont; } const ICont &icont() const { return this->members_.m_icont; } NodeAlloc &node_alloc() { return static_cast
(this->members_); } const NodeAlloc &node_alloc() const { return static_cast
(this->members_); } }; } //namespace detail { } //namespace interprocess { } //namespace boost { #include
#endif // BOOST_INTERPROCESS_DETAIL_NODE_ALLOC_HPP_
node_alloc_holder.hpp
Page URL
File URL
Prev
2/3
Next
Download
( 12 KB )
Note: The DriveHQ service banners will NOT be displayed if the file owner is a paid member.
Comments
Total ratings:
0
Average rating:
Not Rated
Would you like to comment?
Join DriveHQ
for a free account, or
Logon
if you are already a member.