mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-06 03:49:56 +08:00
feat(infra): new doc sync engine (#6205)
https://github.com/toeverything/AFFiNE/blob/eyhn/feat/new-sync/packages/common/infra/src/workspace/engine/doc/README.md
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
export class AsyncLock {
|
||||
private _lock = Promise.resolve();
|
||||
|
||||
async acquire() {
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
let release: () => void = null!;
|
||||
const nextLock = new Promise<void>(resolve => {
|
||||
release = resolve;
|
||||
});
|
||||
|
||||
await this._lock;
|
||||
this._lock = nextLock;
|
||||
return {
|
||||
release,
|
||||
[Symbol.dispose]: () => {
|
||||
release();
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from './async-lock';
|
||||
export * from './async-queue';
|
||||
export * from './merge-updates';
|
||||
export * from './object-pool';
|
||||
|
||||
Reference in New Issue
Block a user