(renderLanes: Lanes)
| 224 | } |
| 225 | |
| 226 | export function requestCacheFromPool(renderLanes: Lanes): Cache { |
| 227 | // Similar to previous function, except if there's not already a cache in the |
| 228 | // pool, we allocate a new one. |
| 229 | const cacheFromPool = peekCacheFromPool(); |
| 230 | if (cacheFromPool !== null) { |
| 231 | return cacheFromPool; |
| 232 | } |
| 233 | |
| 234 | // Create a fresh cache and add it to the root cache pool. A cache can have |
| 235 | // multiple owners: |
| 236 | // - A cache pool that lives on the FiberRoot. This is where all fresh caches |
| 237 | // are originally created (TODO: except during refreshes, until we implement |
| 238 | // this correctly). The root takes ownership immediately when the cache is |
| 239 | // created. Conceptually, root.pooledCache is an Option<Arc<Cache>> (owned), |
| 240 | // and the return value of this function is a &Arc<Cache> (borrowed). |
| 241 | // - One of several fiber types: host root, cache boundary, suspense |
| 242 | // component. These retain and release in the commit phase. |
| 243 | |
| 244 | const root = (getWorkInProgressRoot(): any); |
| 245 | const freshCache = createCache(); |
| 246 | root.pooledCache = freshCache; |
| 247 | retainCache(freshCache); |
| 248 | if (freshCache !== null) { |
| 249 | root.pooledCacheLanes |= renderLanes; |
| 250 | } |
| 251 | return freshCache; |
| 252 | } |
| 253 | |
| 254 | export function pushRootTransition( |
| 255 | workInProgress: Fiber, |
no test coverage detected