MCPcopy Create free account
hub / github.com/apache/arrow / ThreadUnsafeMemoizer

Class ThreadUnsafeMemoizer

cpp/src/arrow/util/cache_internal.h:148–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146
147template <typename Key, typename Value, typename Cache, typename Func>
148struct ThreadUnsafeMemoizer {
149 using RetType = const Value&;
150
151 template <typename F>
152 ThreadUnsafeMemoizer(F&& func, int32_t cache_capacity)
153 : func_(std::forward<F>(func)), cache_(cache_capacity) {}
154
155 const Value& operator()(const Key& key) {
156 const Value* value_ptr;
157 value_ptr = cache_.Find(key);
158 if (ARROW_PREDICT_TRUE(value_ptr != nullptr)) {
159 return *value_ptr;
160 }
161 return *cache_.Replace(key, func_(key)).second;
162 }
163
164 private:
165 Func func_;
166 Cache cache_;
167};
168
169template <template <typename...> class Cache, template <typename...> class MemoizerType,
170 typename Func,

Callers

nothing calls this directly

Calls 2

FindMethod · 0.45
ReplaceMethod · 0.45

Tested by

no test coverage detected