Request a query. If not already cached, the body is spawned onto the executor and a shared handle is stored; concurrent and subsequent requests reuse the same in-flight/completed task.
(self: &Arc<Self>, key: QueryKey)
| 1154 | /// Request a query. If not already cached, the body is spawned onto the executor and a shared |
| 1155 | /// handle is stored; concurrent and subsequent requests reuse the same in-flight/completed task. |
| 1156 | pub fn query(self: &Arc<Self>, key: QueryKey) -> crate::SharedQuery<CachedResult> { |
| 1157 | let me = self.clone(); |
| 1158 | let mut hit = true; |
| 1159 | let query = self.cache.get_or_create(key, || { |
| 1160 | hit = false; |
| 1161 | spawn_shared(me.execute(key).boxed()) |
| 1162 | }); |
| 1163 | if hit { |
| 1164 | crate::perf::count_cache_hit(key.name()); |
| 1165 | } |
| 1166 | query |
| 1167 | } |
| 1168 | |
| 1169 | /// Dispatch a query key to its computation. Each arm may request sub-queries via `self`. |
| 1170 | pub(crate) fn execute(self: Arc<Self>, key: QueryKey) -> BoxFuture<'static, Arc<CachedResult>> { |
no test coverage detected