File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -285,6 +285,24 @@ class Evaluator {
285
285
(*this )(requests)...);
286
286
}
287
287
288
+ // / Cache a precomputed value for the given request, so that it will not
289
+ // / be computed.
290
+ template <typename Request,
291
+ typename std::enable_if<Request::hasExternalCache>::type* = nullptr >
292
+ void cacheOutput (const Request &request,
293
+ typename Request::OutputType &&output) {
294
+ request.cacheResult (std::move (output));
295
+ }
296
+
297
+ // / Cache a precomputed value for the given request, so that it will not
298
+ // / be computed.
299
+ template <typename Request,
300
+ typename std::enable_if<!Request::hasExternalCache>::type* = nullptr >
301
+ void cacheOutput (const Request &request,
302
+ typename Request::OutputType &&output) {
303
+ cache.insert ({getCanonicalRequest (request), std::move (output)});
304
+ }
305
+
288
306
// / Clear the cache stored within this evaluator.
289
307
// /
290
308
// / Note that this does not clear the caches of requests that use external
You can’t perform that action at this time.
0 commit comments