turborepo
a80b3cc7 - Rewrite IdFactory and IdFactoryWithReuse (#8769)

Commit
1 year ago
Rewrite IdFactory and IdFactoryWithReuse (#8769) ### Description The real goal here was to extend `IdFactory<T>` to work with 64-bit ids, which I'll need soon for globally unique (and non-reusable) "execution ids" (#8771) to support the safety requirements of local uncached Vcs. I got a little carried away and essentially rewrote this: - (Debatable if this is an improvement or not) ID generation re-use requires an almost-but-not-entirely-free check of the concurrent queue, so it is now opt-in using the `IdFactoryWithReuse`. - ID generation is always performed with an AtomicU64 (which shouldn't really be any more or less expensive than AtomicU32 on 64 bit architectures). - u32 overflow detection is performed by using a `TryFrom` conversion from a NonZeroU64. Previously we could only detect and panic on the first id generated after overflow. Now we should detect and panic on (basically) all ids generated after overflow. - New versions of `concurrent-queue` make the `unbounded` constructor `const`, which allows us to eliminate the use of `Lazy`. - Add a unit test for overflow detection ### Testing Instructions ``` cargo nextest r -p turbo-tasks -p turbo-tasks-memory ```
Author
bgw bgw
Parents
Loading