-
/*
- * DEBUG: section 77 Delay Pools
- * AUTHOR: Robert Collins <robertc@squid-cache.org>
- *
- * SQUID Web Proxy Cache http://www.squid-cache.org/
- * ----------------------------------------------------------
- *
- * Squid is the result of efforts by numerous individuals from
- * the Internet community; see the CONTRIBUTORS file for full
- * details. Many organizations have provided support for Squid's
- * development; see the SPONSORS file for full details. Squid is
- * Copyrighted (C) 2001 by the Regents of the University of
- * California; see the COPYRIGHT file for full details. Squid
- * incorporates software developed and/or copyrighted by other
- * sources; see the CREDITS file for full details.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * Copyright (C) 1996-2018 The Squid Software Foundation and contributors
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
- *
- *
- * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
*/
+/* DEBUG: section 77 Delay Pools */
+
#include "squid.h"
#if USE_DELAY_POOLS
#include "NullDelayId.h"
#include "Store.h"
-void *
-DelayTagged::operator new(size_t size)
-{
- DelayPools::MemoryUsed += sizeof (DelayTagged);
- return ::operator new (size);
-}
-
-void
-DelayTagged::operator delete (void *address)
-{
- DelayPools::MemoryUsed -= sizeof (DelayTagged);
- ::operator delete (address);
-}
-
DelayTagged::DelayTagged()
{
DelayPools::registerForUpdates (this);
}
-static SplayNode<DelayTaggedBucket::Pointer>::SPLAYFREE DelayTaggedFree;
+static Splay<DelayTaggedBucket::Pointer>::SPLAYFREE DelayTaggedFree;
DelayTagged::~DelayTagged()
{
DelayPools::deregisterForUpdates (this);
- buckets.head->destroy (DelayTaggedFree);
+ buckets.destroy(DelayTaggedFree);
}
-static SplayNode<DelayTaggedBucket::Pointer>::SPLAYCMP DelayTaggedCmp;
+static Splay<DelayTaggedBucket::Pointer>::SPLAYCMP DelayTaggedCmp;
int
DelayTaggedCmp(DelayTaggedBucket::Pointer const &left, DelayTaggedBucket::Pointer const &right)
DelayTaggedFree(DelayTaggedBucket::Pointer &)
{}
-void
-DelayTaggedStatsWalkee(DelayTaggedBucket::Pointer const ¤t, void *state)
-{
- current->stats ((StoreEntry *)state);
-}
+struct DelayTaggedStatsVisitor {
+ StoreEntry *sentry;
+ explicit DelayTaggedStatsVisitor(StoreEntry *se): sentry(se) {}
+ void operator() (DelayTaggedBucket::Pointer const ¤t) {
+ current->stats(sentry);
+ }
+};
void
DelayTagged::stats(StoreEntry * sentry)
storeAppendPrintf(sentry, "\t\tCurrent: ");
- if (!buckets.head) {
+ if (buckets.empty()) {
storeAppendPrintf (sentry, "Not used yet.\n\n");
return;
}
- buckets.head->walk(DelayTaggedStatsWalkee, sentry);
+ DelayTaggedStatsVisitor visitor(sentry);
+ buckets.visit(visitor);
storeAppendPrintf(sentry, "\n\n");
}
const_cast<DelayTaggedBucket *>(current.getRaw())->theBucket.update(t->spec, t->incr);
}
+struct DelayTaggedUpdateVisitor {
+ DelayTaggedUpdater *updater;
+ explicit DelayTaggedUpdateVisitor(DelayTaggedUpdater *u) : updater(u) {}
+ void operator() (DelayTaggedBucket::Pointer const ¤t) {
+ const_cast<DelayTaggedBucket *>(current.getRaw())->theBucket.update(updater->spec, updater->incr);
+ }
+};
+
void
DelayTagged::update(int incr)
{
DelayTaggedUpdater updater(spec, incr);
- buckets.head->walk (DelayTaggedUpdateWalkee, &updater);
+ DelayTaggedUpdateVisitor visitor(&updater);
+ buckets.visit(visitor);
kickReads();
}
return new Id(this, details.tag);
}
-void *
-DelayTagged::Id::operator new(size_t size)
-{
- DelayPools::MemoryUsed += sizeof (Id);
- return ::operator new (size);
-}
-
-void
-DelayTagged::Id::operator delete (void *address)
-{
- DelayPools::MemoryUsed -= sizeof (Id);
- ::operator delete (address);
-}
-
-void *
-DelayTaggedBucket::operator new(size_t size)
-{
- DelayPools::MemoryUsed += sizeof (DelayTaggedBucket);
- return ::operator new (size);
-}
-
-void
-DelayTaggedBucket::operator delete (void *address)
-{
- DelayPools::MemoryUsed -= sizeof (DelayTaggedBucket);
- ::operator delete (address);
-}
-
DelayTaggedBucket::DelayTaggedBucket(String &aTag) : tag (aTag)
{
debugs(77, 3, "DelayTaggedBucket::DelayTaggedBucket");
}
theBucket->theBucket.init(theTagged->spec);
- theTagged->buckets.head = theTagged->buckets.head->insert (theBucket, DelayTaggedCmp);
+ theTagged->buckets.insert (theBucket, DelayTaggedCmp);
}
DelayTagged::Id::~Id()
}
#endif
+