Fix resetting
This commit is contained in:
parent
d8058d396c
commit
c94d732f24
11 changed files with 161 additions and 56 deletions
|
|
@ -89,7 +89,7 @@ describe("fixedSizeDocumentCache", () => {
|
|||
assert.equal(cache.get(1), doc1);
|
||||
assert.equal(cache.get(2), doc2);
|
||||
|
||||
cache.clear();
|
||||
cache.reset();
|
||||
assert.equal(cache.get(1), undefined);
|
||||
assert.equal(cache.get(2), undefined);
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ export class FixedSizeDocumentCache {
|
|||
this.fitBelowMaxSize();
|
||||
}
|
||||
|
||||
public clear(): void {
|
||||
public reset(): void {
|
||||
this.cache.clear();
|
||||
this.head = null;
|
||||
this.tail = null;
|
||||
|
|
|
|||
|
|
@ -131,6 +131,11 @@ export class Locks<T> {
|
|||
this.locked.delete(key);
|
||||
}
|
||||
}
|
||||
|
||||
public reset(): void {
|
||||
this.locked.clear();
|
||||
this.waiters.clear();
|
||||
}
|
||||
}
|
||||
|
||||
export class Lock {
|
||||
|
|
@ -143,4 +148,8 @@ export class Lock {
|
|||
public async withLock<R>(fn: () => R | Promise<R>): Promise<R> {
|
||||
return this.locks.withLock(true, fn);
|
||||
}
|
||||
|
||||
public reset(): void {
|
||||
this.locks.reset();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue