polachok / fahrenheit

toy futures executor 🚒📖🔥
Other
233 stars 23 forks source link

remove unnecessary `RefCell<Option>` around reactor #1

Closed nivkner closed 6 years ago

nivkner commented 6 years ago

When the Reactor is None, you either ignore it or panic, which means that for the most part the reactor is assumed to exist. By just creating it in the thread local storage you ensure the assumption is correct.

As the documentation states, the TLS key is lazily initialized anyway so using an Option is redundant.

The only reason RefCell is used is to create the reactor once on the creation of Core, while the cost of run-time borrow-checking (and None check) exists on every use of the reactor.