]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/DelayUser.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / DelayUser.cc
index 5e62bffd1bfd15f1f0480d4f4a7e166887b0e465..72220bafc569df257fdf64fae15a8e941d51c8ba 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
+ * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
  *
  * Squid software is distributed under GPLv2+ license and includes
  * contributions from numerous individuals and organizations.
@@ -42,7 +42,7 @@ static Splay<DelayUserBucket::Pointer>::SPLAYFREE DelayUserFree;
 DelayUser::~DelayUser()
 {
     DelayPools::deregisterForUpdates (this);
-    buckets.head->destroy (DelayUserFree);
+    buckets.destroy(DelayUserFree);
 }
 
 static Splay<DelayUserBucket::Pointer>::SPLAYCMP DelayUserCmp;
@@ -68,6 +68,14 @@ DelayUserStatsWalkee(DelayUserBucket::Pointer const &current, void *state)
     current->stats ((StoreEntry *)state);
 }
 
+struct DelayUserStatsVisitor {
+    StoreEntry *se;
+    explicit DelayUserStatsVisitor(StoreEntry *s) : se(s) {}
+    void operator() (DelayUserBucket::Pointer const &current) {
+        current->stats(se);
+    }
+};
+
 void
 DelayUser::stats(StoreEntry * sentry)
 {
@@ -78,12 +86,13 @@ DelayUser::stats(StoreEntry * sentry)
 
     storeAppendPrintf(sentry, "\t\tCurrent: ");
 
-    if (!buckets.head) {
+    if (buckets.empty()) {
         storeAppendPrintf (sentry, "Not used yet.\n\n");
         return;
     }
 
-    buckets.head->walk(DelayUserStatsWalkee, sentry);
+    DelayUserStatsVisitor visitor(sentry);
+    buckets.visit(visitor);
     storeAppendPrintf(sentry, "\n\n");
 }
 
@@ -108,11 +117,20 @@ DelayUserUpdateWalkee(DelayUserBucket::Pointer const &current, void *state)
     const_cast<DelayUserBucket *>(current.getRaw())->theBucket.update(t->spec, t->incr);
 }
 
+struct DelayUserUpdateVisitor {
+    DelayUserUpdater *t;
+    DelayUserUpdateVisitor(DelayUserUpdater *updater) : t(updater) {}
+    void operator() (DelayUserBucket::Pointer const &current) {
+        const_cast<DelayUserBucket *>(current.getRaw())->theBucket.update(t->spec, t->incr);
+    }
+};
+
 void
 DelayUser::update(int incr)
 {
     DelayUserUpdater updater(spec, incr);
-    buckets.head->walk (DelayUserUpdateWalkee, &updater);
+    DelayUserUpdateVisitor visitor(&updater);
+    buckets.visit(visitor);
 }
 
 void
@@ -188,7 +206,7 @@ DelayUser::Id::Id(DelayUser::Pointer aDelayUser, Auth::User::Pointer aUser) : th
     }
 
     theBucket->theBucket.init(theUser->spec);
-    theUser->buckets.head = theUser->buckets.head->insert (theBucket, DelayUserCmp);
+    theUser->buckets.insert (theBucket, DelayUserCmp);
 }
 
 DelayUser::Id::~Id()