GGStoragePoolsImpl.mesa
Contents: Routines for maintaining various storage pools and synchronizing their use. Synchronization is the main reason for the existence of this module. It provides a MONITOR lock for each storage pool.
Copyright © 1986 by Xerox Corporation. All rights reserved.
Bier, June 5, 1987 2:02:43 pm PDT
DIRECTORY
GGStoragePools;
GGStoragePoolsImpl: CEDAR MONITOR LOCKS pool USING pool: StoragePool
EXPORTS GGStoragePools =
BEGIN
MakeStorageProc: TYPE = GGStoragePools.MakeStorageProc;
AllocateProc: TYPE = GGStoragePools.AllocateProc;
FreeProc: TYPE = GGStoragePools.FreeProc;
StoragePoolClass: TYPE = REF StoragePoolClassObj;
StoragePoolClassObj: TYPE = GGStoragePools.StoragePoolClassObj;
StoragePool: TYPE = REF StoragePoolObj;
StoragePoolObj: TYPE = GGStoragePools.StoragePoolObj;
CreateClass: PUBLIC PROC [name: ATOM, allocate: AllocateProc, free: FreeProc] RETURNS [class: StoragePoolClass] = {
class ← NEW[StoragePoolClassObj ← [name, allocate, free]];
};
CreatePool: PUBLIC PROC [class: StoragePoolClass, makeStorage: MakeStorageProc] RETURNS [pool: StoragePool] = {
Creates a new pool and runs its initialize proc.
pool ← NEW[StoragePoolObj ← [class: class, data: NIL]];
makeStorage[pool];
};
Allocate: PUBLIC ENTRY PROC [pool: StoragePool] RETURNS [item: REF ANY] = {
item ← pool.class.allocate[pool];
};
Free: PUBLIC ENTRY PROC [pool: StoragePool, item: REF ANY] = {
pool.class.free[pool, item];
};
END.