]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/mem_node.cc
3 * $Id: mem_node.cc,v 1.10 2007/08/13 17:20:51 hno Exp $
5 * DEBUG: section 19 Store Memory Primitives
6 * AUTHOR: Robert Collins
8 * SQUID Web Proxy Cache http://www.squid-cache.org/
9 * ----------------------------------------------------------
11 * Squid is the result of efforts by numerous individuals from
12 * the Internet community; see the CONTRIBUTORS file for full
13 * details. Many organizations have provided support for Squid's
14 * development; see the SPONSORS file for full details. Squid is
15 * Copyrighted (C) 2001 by the Regents of the University of
16 * California; see the COPYRIGHT file for full details. Squid
17 * incorporates software developed and/or copyrighted by other
18 * sources; see the CREDITS file for full details.
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 2 of the License, or
23 * (at your option) any later version.
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, write to the Free Software
32 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
39 static int makeMemNodeDataOffset();
41 unsigned long mem_node::store_mem_size
;
42 static int _mem_node_data_offset
= makeMemNodeDataOffset();
45 * Calculate the offset between the start of a mem_node and
49 makeMemNodeDataOffset()
52 return int(ptrdiff_t(&p
->data
));
56 * This is the callback when storeIOWrite() is done. We need to
57 * clear the write_pending flag for the mem_node. First we have
58 * to calculate the start of the mem_node based on the character
59 * buffer that we wrote. ick.
62 memNodeWriteComplete(void* d
)
64 mem_node
* n
= (mem_node
*)((char*)d
- _mem_node_data_offset
);
65 assert(n
->write_pending
);
69 mem_node::mem_node(int64_t offset
):nodeBuffer(0,offset
,data
)
74 store_mem_size
-= nodeBuffer
.length
;
78 mem_node::InUseCount()
80 return Pool().inUseCount();
84 mem_node::start() const
86 assert (nodeBuffer
.offset
>= 0);
87 return nodeBuffer
.offset
;
93 return nodeBuffer
.offset
+ nodeBuffer
.length
;
97 mem_node::dataRange() const
99 return Range
<int64_t> (start(), end());
103 mem_node::space() const
105 return SM_PAGE_SIZE
- nodeBuffer
.length
;
109 mem_node::contains (int64_t const &location
) const
111 if (start() <= location
&& end() > location
)
117 /* nodes can not be sparse */
119 mem_node::canAccept (int64_t const &location
) const
121 if (location
== end() && space() > 0)
128 mem_node::operator < (mem_node
const & rhs
) const
130 return start() < rhs
.start();