core: change FutureState Forced(A) to Forced(~A)

This commit is contained in:
Jeff Olson 2012-09-07 13:11:03 -07:00 committed by Brian Anderson
parent 2ed00ff928
commit 6d84d86736

View file

@ -43,7 +43,7 @@ struct Future<A> {
priv enum FutureState<A> { priv enum FutureState<A> {
Pending(fn~() -> A), Pending(fn~() -> A),
Evaluating, Evaluating,
Forced(A) Forced(~A)
} }
/// Methods on the `future` type /// Methods on the `future` type
@ -75,7 +75,7 @@ fn from_value<A>(+val: A) -> Future<A> {
* not block. * not block.
*/ */
Future {state: Forced(val)} Future {state: Forced(~val)}
} }
fn from_port<A:Send>(+port: future_pipe::client::waiting<A>) -> Future<A> { fn from_port<A:Send>(+port: future_pipe::client::waiting<A>) -> Future<A> {
@ -139,7 +139,7 @@ fn get_ref<A>(future: &r/Future<A>) -> &r/A {
match future.state { match future.state {
Forced(ref v) => { // v here has type &A, but with a shorter lifetime. Forced(ref v) => { // v here has type &A, but with a shorter lifetime.
return unsafe{ copy_lifetime(future, v) }; // ...extend it. return unsafe{ copy_lifetime(future, &**v) }; // ...extend it.
} }
Evaluating => { Evaluating => {
fail ~"Recursive forcing of future!"; fail ~"Recursive forcing of future!";
@ -154,7 +154,7 @@ fn get_ref<A>(future: &r/Future<A>) -> &r/A {
fail ~"Logic error."; fail ~"Logic error.";
} }
Pending(move f) => { Pending(move f) => {
future.state = Forced(f()); future.state = Forced(~f());
return get_ref(future); return get_ref(future);
} }
} }