19 #ifndef PAGESPEED_KERNEL_CACHE_CACHE_BATCHER_H_
20 #define PAGESPEED_KERNEL_CACHE_CACHE_BATCHER_H_
24 #include <unordered_map>
33 #include "pagespeed/kernel/base/thread_annotations.h"
34 #include "pagespeed/kernel/cache/cache_interface.h"
36 namespace net_instaweb {
81 int max_parallel_lookups;
100 static GoogleString FormatName(StringPiece cache,
int parallelism,
int max);
110 typedef std::unordered_map<GoogleString, std::vector<Callback*>> CallbackMap;
115 bool CanIssueGet() const EXCLUSIVE_LOCKS_REQUIRED(mutex_);
116 bool CanQueueCallback() const EXCLUSIVE_LOCKS_REQUIRED(mutex_);
117 void GroupComplete();
119 MultiGetRequest* ConvertMapToRequest(const CallbackMap& map)
120 EXCLUSIVE_LOCKS_REQUIRED(mutex_);
121 MultiGetRequest* CreateRequestForQueuedKeys()
122 EXCLUSIVE_LOCKS_REQUIRED(mutex_);
123 void MoveQueuedKeys() EXCLUSIVE_LOCKS_REQUIRED(mutex_);
126 LOCKS_EXCLUDED(mutex_);
128 void DecrementInFlightGets(
int n) LOCKS_EXCLUDED(mutex_);
132 int last_batch_size() const LOCKS_EXCLUDED(mutex_);
133 int num_in_flight_keys() LOCKS_EXCLUDED(mutex_);
139 CallbackMap in_flight_ GUARDED_BY(mutex_);
140 int last_batch_size_ GUARDED_BY(mutex_);
142 int num_in_flight_groups_ GUARDED_BY(mutex_);
143 int num_in_flight_keys_ GUARDED_BY(mutex_);
144 int num_pending_gets_ GUARDED_BY(mutex_);
146 CallbackMap queued_ GUARDED_BY(mutex_);
147 bool shutdown_ GUARDED_BY(mutex_);
Definition: cache_batcher_testing_peer.h:28
Abstract interface for a cache.
Definition: cache_interface.h:32
virtual void Put(const GoogleString &key, const SharedString &value)
Definition: statistics.h:43
static const size_t kDefaultMaxPendingGets
Definition: cache_batcher.h:73
Base class for implementations of monitoring statistics.
Definition: statistics.h:342
Abstract interface for implementing a mutex.
Definition: abstract_mutex.h:28
virtual GoogleString Name() const
static void InitStats(Statistics *statistics)
virtual void Get(const GoogleString &key, Callback *callback)
Definition: scoped_ptr.h:30
Definition: cache_batcher.h:54
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
CacheBatcher(const Options &options, CacheInterface *cache, AbstractMutex *mutex, Statistics *statistics)
Does not take ownership of the cache. Takes ownership of the mutex.
virtual bool IsHealthy() const
Definition: cache_batcher.h:106
virtual bool IsHealthy() const =0
Definition: cache_batcher.h:75
virtual bool IsBlocking() const =0
static const int kDefaultMaxParallelLookups
Definition: cache_batcher.h:67
Definition: shared_string.h:40
virtual bool IsBlocking() const
Definition: cache_batcher.h:104
Definition: cache_interface.h:42