LookupLock:
PUBLIC
ENTRY
PROC [prefix, nameBody:
ROPE, version: FSBackdoor.Version]
RETURNS [a: FSLock.ActiveFile] = {
ENABLE UNWIND => NULL;
hash: CARDINAL;
IF NOT Rope.Match["[*", nameBody] THEN nameBody ← Rope.Concat[prefix, nameBody];
hash ← RopeHash.FromRope[rope: nameBody, case: FALSE, seed: version] MOD buckets;
stats.lookups ← stats.lookups + 1;
FOR a ← lockTbl[hash], a.next
UNTIL a =
NIL
DO
IF version = a.version AND Rope.Equal[nameBody, a.nameBody, FALSE] THEN RETURN;
ENDLOOP;
stats.newActiveFiles ← stats.newActiveFiles + 1;
a ← NEW [FSLock.ActiveFileObject];
a.nameBody ← nameBody;
a.version ← version;
a.h ← NIL;
a.fileLock ← none;
a.recordLock ← FALSE;
a.fileLockCount ← 0;
a.attachedTo ← NIL;
a.next ← lockTbl[hash];
lockTbl[hash] ← a;
};
RemoveLock:
PUBLIC
ENTRY
PROC [a: FSLock.ActiveFile] = {
ENABLE UNWIND => NULL;
hash: CARDINAL = RopeHash.FromRope[rope: a.nameBody, case: FALSE, seed: a.version] MOD buckets;
aPrev: FSLock.ActiveFile ← lockTbl[hash];
stats.removals ← stats.removals + 1;
IF aPrev = a
THEN lockTbl[hash] ← a.next
ELSE
DO
IF aPrev.next = a THEN {aPrev.next ← a.next; EXIT};
aPrev ← aPrev.next;
ENDLOOP;
a.nameBody ← NIL;
};
RecordREF:
PUBLIC
ENTRY
PROC [r:
REF] = {
p: REF PRTEntry = NEW [PRTEntry];
hash: CARDINAL = RefHash[r];
p.ref ← r;
p.chain ← prt[hash];
prt[hash] ← p;
stats.prtRecorded ← stats.prtRecorded + 1;
};