]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/mem_node.cc
2 * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 /* DEBUG: section 19 Store Memory Primitives */
15 static ptrdiff_t makeMemNodeDataOffset();
17 static ptrdiff_t _mem_node_data_offset
= makeMemNodeDataOffset();
20 * Calculate the offset between the start of a mem_node and
24 makeMemNodeDataOffset()
27 return ptrdiff_t(&p
->data
);
31 * This is the callback when storeIOWrite() is done. We need to
32 * clear the write_pending flag for the mem_node. First we have
33 * to calculate the start of the mem_node based on the character
34 * buffer that we wrote. ick.
37 memNodeWriteComplete(void* d
)
39 mem_node
* n
= (mem_node
*)((char*)d
- _mem_node_data_offset
);
40 assert(n
->write_pending
);
41 n
->write_pending
= false;
44 mem_node::mem_node(int64_t offset
) :
45 nodeBuffer(0,offset
,data
),
55 mem_node::InUseCount()
57 return Pool().inUseCount();
61 mem_node::StoreMemSize()
63 return InUseCount() * SM_PAGE_SIZE
;
67 mem_node::start() const
69 assert (nodeBuffer
.offset
>= 0);
70 return nodeBuffer
.offset
;
76 return nodeBuffer
.offset
+ nodeBuffer
.length
;
80 mem_node::dataRange() const
82 return Range
<int64_t> (start(), end());
86 mem_node::space() const
88 return SM_PAGE_SIZE
- nodeBuffer
.length
;
92 mem_node::contains (int64_t const &location
) const
94 if (start() <= location
&& end() > location
)
100 /* nodes can not be sparse */
102 mem_node::canAccept (int64_t const &location
) const
104 if (location
== end() && space() > 0)
111 mem_node::operator < (mem_node
const & rhs
) const
113 return start() < rhs
.start();