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::futureprovides a read-only view. The value is set directly by using astd::promise, or set to the result of a function call usingstd::packaged_taskorstd::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.Taskrepresents 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:
“A foreign minister, I will maintain it, can never be a good man of business if he is not an agreeable man of pleasure too. Half his business is done by the help of his pleasures: his views are carried on, and perhaps best, and most unsuspectedly, at balls, suppers, assemblies, and parties of pleasure; by intrigues with women, and connections insensibly formed with men, at those unguarded hours of amusement.”
—Philip Dormer Stanhope, 4th Earl Chesterfield (16941773)