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:
“Views of women, on one side, as inwardly directed toward home and family and notions of men, on the other, as outwardly striving toward fame and fortune have resounded throughout literature and in the texts of history, biology, and psychology until they seem uncontestable. Such dichotomous views defy the complexities of individuals and stifle the potential for people to reveal different dimensions of themselves in various settings.”
—Sara Lawrence Lightfoot (20th century)