1 /*
2  * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
3  *
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.
7  */
8 
9 /* DEBUG: section 77    Delay Pools */
10 
11 #ifndef DELAYTAGGED_H
12 #define DELAYTAGGED_H
13 
14 #if USE_DELAY_POOLS
15 
16 #include "auth/Gadgets.h"
17 #include "CompositePoolNode.h"
18 #include "DelayBucket.h"
19 #include "DelayIdComposite.h"
20 #include "DelaySpec.h"
21 #include "splay.h"
22 
23 /// \ingroup DelayPoolsAPI
24 class DelayTaggedBucket : public RefCountable
25 {
26     MEMPROXY_CLASS(DelayTaggedBucket);
27 
28 public:
29     typedef RefCount<DelayTaggedBucket> Pointer;
30 
31     void stats(StoreEntry *)const;
32     DelayTaggedBucket(String &aTag);
33     ~DelayTaggedBucket();
34     DelayBucket theBucket;
35     String tag;
36 };
37 
38 /// \ingroup DelayPoolsAPI
39 class DelayTagged : public CompositePoolNode
40 {
41     MEMPROXY_CLASS(DelayTagged);
42 
43 public:
44     typedef RefCount<DelayTagged> Pointer;
45 
46     DelayTagged();
47     virtual ~DelayTagged();
48     virtual void stats(StoreEntry * sentry);
49     virtual void dump(StoreEntry *entry) const;
50     virtual void update(int incr);
51     virtual void parse();
52 
53     virtual DelayIdComposite::Pointer id(CompositeSelectionDetails &);
54 
55 private:
56 
57     /// \ingroup DelayPoolsInternal
58     class Id:public DelayIdComposite
59     {
60         MEMPROXY_CLASS(DelayTagged::Id);
61 
62     public:
63         Id (RefCount<DelayTagged>, String &);
64         ~Id();
65         virtual int bytesWanted (int min, int max) const;
66         virtual void bytesIn(int qty);
67         virtual void delayRead(DeferredRead const &);
68 
69     private:
70         RefCount<DelayTagged> theTagged;
71         DelayTaggedBucket::Pointer theBucket;
72     };
73 
74     friend class Id;
75 
76     DelaySpec spec;
77     Splay<DelayTaggedBucket::Pointer> buckets;
78 };
79 
80 #endif /* USE_DELAY_POOLS */
81 #endif /* DELAYTAGGED_H */
82 
83