@richie696/react-framework-concurrency
v1.0.2
Published
Framework-neutral async concurrency primitives for Richie696 applications.
Maintainers
Readme
@richie696/react-framework-concurrency
📚 Monorepo 文档 · 📦 包结构 · 💻 GitHub · 🐛 Issues · 🤝 贡献 · 🛡️ 安全 · 📄 License
Async concurrency primitives for cooperating tasks in one JavaScript runtime.
Installation
pnpm add @richie696/react-framework-concurrencyPublic capabilities
AsyncMutexandSingleFlightfor serialization and shared in-flight work.ReentrantLockwith explicitLockOwnertokens, fairness, cancellation andConditionsupport.ReadWriteLockfor shared readers and an exclusive reentrant writer.StampedLockfor optimistic-read validation.Condition,LockError,LockErrorCodeandcreateLockOwner.
Example
import { ReentrantLock, createLockOwner } from '@richie696/react-framework-concurrency';
const lock = new ReentrantLock();
const owner = createLockOwner('cache-update');
await lock.runExclusiveWith(owner, async () => {
// One cooperating async task at a time.
});Locks are not cross-tab, cross-worker or cross-process synchronization. Always release explicit lock holds, preferably through runExclusive, runRead or runWrite.
See the repository LICENSE and security policy.
