Read-only Views
In some programming languages such as Oz, E, and AmbientTalk, it is possible to obtain a read-only view of a future, which allows reading its value when resolved, but does not permit resolving it:
- In Oz, the !! operator is used to obtain a read-only view.
- In E and AmbientTalk, a future is represented by a pair of values called a promise/resolver pair. The promise represents the read-only view, and the resolver is needed in order to set the future's value.
- In C++11 a
std::future
provides a read-only view. The value is set directly by using astd::promise
, or set to the result of a function call usingstd::packaged_task
orstd::async
. - In the Dojo Toolkit's Deferred API as of version 1.5, a consumer-only promise object represents a read-only view.
- In Alice ML, futures only provide a read-only view, whereas a promise contains both a future and the ability to resolve the future
- In .NET 4.0
System.Threading.Tasks.Task
represents a read-only view. Resolving the value can be done throughSystem.Threading.Tasks.TaskCompletionSource
.
Support for read-only views is consistent with the Principle of Least Authority, since it enables the ability to set the value to be restricted to subjects that need to set it. In a system that also supports pipelining, the sender of an asynchronous message (with result) receives the read-only promise for the result, and the target of the message receives the resolver.
Read more about this topic: Futures And Promises
Famous quotes containing the word views:
“The word conservative is used by the BBC as a portmanteau word of abuse for anyone whose views differ from the insufferable, smug, sanctimonious, naive, guilt-ridden, wet, pink orthodoxy of that sunset home of the third-rate minds of that third-rate decade, the nineteen-sixties.”
—Norman Tebbit (b. 1931)