3 * $Id: MemObject.h,v 1.15 2007/08/13 17:20:51 hno Exp $
6 * SQUID Web Proxy Cache http://www.squid-cache.org/
7 * ----------------------------------------------------------
9 * Squid is the result of efforts by numerous individuals from
10 * the Internet community; see the CONTRIBUTORS file for full
11 * details. Many organizations have provided support for Squid's
12 * development; see the SPONSORS file for full details. Squid is
13 * Copyrighted (C) 2001 by the Regents of the University of
14 * California; see the COPYRIGHT file for full details. Squid
15 * incorporates software developed and/or copyrighted by other
16 * sources; see the CREDITS file for full details.
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
34 #ifndef SQUID_MEMOBJECT_H
35 #define SQUID_MEMOBJECT_H
37 #include "StoreIOBuffer.h"
38 #include "StoreIOState.h"
41 #include "RemovalPolicy.h"
43 typedef void STMCB (void *data
, StoreIOBuffer wroteBuffer
);
54 static size_t inUseCount();
55 MEMPROXY_CLASS(MemObject
);
58 MemObject(char const *, char const *);
61 void write(StoreIOBuffer
, STMCB
*, void *);
63 HttpReply
const *getReply() const;
64 void replaceHttpReply(HttpReply
*newrep
);
65 void stat (MemBuf
* mb
) const;
66 int64_t endOffset () const;
69 int64_t lowestMemReaderOffset() const;
70 bool readAheadPolicyCanRead() const;
71 void addClient(store_client
*);
72 /* XXX belongs in MemObject::swapout, once swaphdrsz is managed
75 int64_t objectBytesOnDisk() const;
76 int64_t policyLowestOffsetToKeep() const;
78 void trimUnSwappable();
79 bool isContiguous() const;
80 int mostBytesWanted(int max
) const;
81 void setNoDelay(bool const newValue
);
84 DelayId
mostBytesAllowed() const;
88 #if URL_CHECKSUM_DEBUG
90 void checkUrlChecksum() const;
98 /* TODO: move into .cc or .cci */
99 size_t clientCount() const {return nclients
;}
101 bool clientIsFirst(void *sc
) const {return (clients
.head
&& sc
== clients
.head
->data
);}
109 int64_t queue_offset
; /* relative to in-mem data */
110 mem_node
*memnode
; /* which node we're currently paging out */
111 StoreIOState::Pointer sio
;
115 /* Read only - this reply must be preserved by store clients */
116 /* The original reply. possibly with updated metadata. */
117 HttpRequest
*request
;
119 struct timeval start_ping
;
120 IRCB
*ping_reply_callback
;
131 RemovalPolicyNode repl
;
135 #if URL_CHECKSUM_DEBUG
140 const char *vary_headers
;
142 void delayRead(DeferredRead
const &);
148 DeferredReadManager deferredReads
;
151 MEMPROXY_CLASS_INLINE(MemObject
)
153 /* global current memory removal policy */
154 extern RemovalPolicy
*mem_policy
;
156 #endif /* SQUID_MEMOBJECT_H */