GiveAndTake.mesa
Copyright Ó 1990, 1991, 1992 by Xerox Corporation. All rights reserved.
Last changed by Pavel on April 24, 1990 2:01 pm PDT
Michael Plass, January 23, 1992 12:28 pm PST
DIRECTORY
BasicTime USING [GMT],
Rope USING [ROPE];
GiveAndTake: CEDAR DEFINITIONS
~ BEGIN
ROPE: TYPE ~ Rope.ROPE;
GMT: TYPE ~ BasicTime.GMT;
defaultWorldName: ROPE;
NoSuchPackage: ERROR [packageName: ROPE, worldName: ROPE];
MalformedTorch: SIGNAL [packageName: ROPE, worldName: ROPE];
This signal is usually not resumable. Only EnumerateTakenPackages raises it resumably.
TakePackage: PROC [packageName: ROPE, worldName: ROPE ¬ defaultWorldName, forcibly: BOOL ¬ FALSE] RETURNS [ok: BOOL, owner: ROPE, takenDate: GMT];
Attempts to grab the torch for the named package in the named world, with the new owner being the current user. ok is TRUE if the grab was successful (i.e., the torch was free). If forcibly, then the grab always succeeds, stealing the torch from the former owner. owner and takenDate describe the current owner of the torch and when they grabbed it, regardless of whether or not ok is TRUE.
! NoSuchPackage, MalformedTorch, PFS.Error
GivePackage: PROC [packageName: ROPE, worldName: ROPE ¬ defaultWorldName] RETURNS [yoursToGive: BOOL];
Releases the torch for the named package in the named world if it's owned by the current user, returning FALSE otherwise.
! NoSuchPackage, MalformedTorch, PFS.Error
PackageTaken: PROC [packageName: ROPE, worldName: ROPE ¬ defaultWorldName] RETURNS [taken: BOOL, owner: ROPE, takenDate: GMT];
Determines whether or not the torch for the named package in the named world is free and, if so, who grabbed it and when.
! NoSuchPackage, MalformedTorch, PFS.Error
PackageMine: PROC [packageName: ROPE, worldName: ROPE ¬ defaultWorldName] RETURNS [BOOL];
Determines whether or not the torch for the named package in the named world is owned by the current user
! NoSuchPackage, MalformedTorch, PFS.Error
EnumerateTakenPackages: PROC [worldName: ROPE ¬ defaultWorldName, proc: PROC [packageName: ROPE, owner: ROPE, takenDate: GMT] RETURNS [quit: BOOL ¬ FALSE]];
Calls proc on the pertinent information about every currently-grabbed torch in the named world. The enumeration halts if quit is ever TRUE.
! MalformedTorch, PFS.Error
END.