Commit f7f840c3 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Use terminate_with in Futures Core invalid transitions

Summary:
[Folly] Use `terminate_with` in Futures `Core` invalid transitions.

Both `Promise` and `Future` check state validity before calling the `Core` transition methods and throws in invalid state. So `Core` no longer needs to throw and may terminate instead.

Reviewed By: marshallcline

Differential Revision: D8346113

fbshipit-source-id: 9ff158673149096789b29544453262797b06d441
parent a711f13b
......@@ -287,11 +287,9 @@ class Core final {
return fsm_.tryUpdateState(
state, State::Done, setCallback_, [&] { doCallback(); });
case State::OnlyCallback:
case State::Done:
throw_exception<std::logic_error>("setCallback called twice");
default:
terminate_with<std::logic_error>("setCallback unexpected state");
}
assume_unreachable();
});
}
......@@ -314,11 +312,9 @@ class Core final {
return fsm_.tryUpdateState(
state, State::Done, setResult_, [&] { doCallback(); });
case State::OnlyResult:
case State::Done:
throw_exception<std::logic_error>("setResult called twice");
default:
terminate_with<std::logic_error>("setResult unexpected state");
}
assume_unreachable();
});
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment