Clear the thread-local mixin resolution cache. In production the cache lives for the lifetime of the thread and is safe because the same FQN always maps to the same class. In tests, however, each test may define classes with identical short names but different members. Call this function when creating a new test backend so that stale entries from a previous test do not leak.
()
| 66 | /// different members. Call this function when creating a new test |
| 67 | /// backend so that stale entries from a previous test do not leak. |
| 68 | pub fn clear_mixin_cache() { |
| 69 | MIXIN_CACHE.with(|cache| { |
| 70 | let mut inner = cache.borrow_mut(); |
| 71 | inner.0 = MIXIN_GENERATION.load(Ordering::Relaxed); |
| 72 | inner.1.clear(); |
| 73 | }); |
| 74 | } |
| 75 | |
| 76 | /// Ensure the thread-local cache is current with the global generation. |
| 77 | /// Clears the cache if stale. |