FutureValuesImpl.mesa
Copyright © 1992 by Xerox Corporation. All rights reserved.
Bier, June 30, 1993 10:43 pm PDT
Contents: A mechanism that allows one application to place a request for a value on another application's queue and then block until the data is available.
DIRECTORY
FutureValues, Process;
FutureValuesImpl:
CEDAR
MONITOR
IMPORTS Process
EXPORTS FutureValues = BEGIN
FutureValue: TYPE = FutureValues.FutureValue;
FutureValueObj: TYPE = FutureValues.FutureValueObj;
Routines for Consumers of FutureValues
Create:
PUBLIC
PROC []
RETURNS [fv: FutureValue] = {
Allocate a new FutureValue record to be included in a Gargoyle event.
fv ¬ NEW[FutureValueObj];
};
WaitFor:
PUBLIC
ENTRY PROC [fv: FutureValue, useTimeout:
BOOL ¬
FALSE, timeoutMSec:
CARD ¬ 1000] = {
TRUSTED {
IF useTimeout
THEN
Process.SetTimeout[@fv.availableNow, Process.MsecToTicks[timeoutMSec]];
};
WAIT fv.availableNow; -- if timeout occurs, value will still be NIL, and fv.available will be FALSE;
};
Routines for Producers of FutureValues
NowAvailable:
PUBLIC
ENTRY PROC [fv: FutureValue] = {
Informs the thread(s) that is(are) waiting for this future value that it is now available.
fv.available ¬ TRUE;
BROADCAST fv.availableNow;
};
END.