19#include <boost/intrusive_ptr.hpp>
21#include "mongo/platform/atomic_word.h"
30 _holder.swap(other._holder);
43 return takeOwnership(
static_cast<char*
>(malloc(
sizeof(Holder) + bytes)));
64 return _holder ? _holder->data() : NULL;
69 explicit Holder(AtomicUInt32::WordType initial = AtomicUInt32::WordType())
70 : _refCount(initial) {}
73 friend void intrusive_ptr_add_ref(
Holder* h) {
74 h->_refCount.fetchAndAdd(1);
77 friend void intrusive_ptr_release(
Holder* h) {
78 if (h->_refCount.subtractAndFetch(1) == 0) {
87 return reinterpret_cast<char *
>(
this + 1);
90 const char* data()
const {
91 return reinterpret_cast<const char *
>(
this + 1);
95 AtomicUInt32 _refCount;
100 : _holder(holder, false) {
105 boost::intrusive_ptr<Holder> _holder;
108 inline void swap(SharedBuffer& one, SharedBuffer& two) {
Definition shared_buffer.h:67
Definition shared_buffer.h:25
static SharedBuffer takeOwnership(char *holderPrefixedData)
Given a pointer to a region of un-owned data, prefixed by sufficient space for a SharedBuffer::Holder...
Definition shared_buffer.h:54
SharedBuffer moveFrom()
C++03 compatible way of writing std::move(someSharedBuffer)
Definition shared_buffer.h:36
the main MongoDB namespace
Definition bulk_operation_builder.h:24