Open
Description
I tend to not analyze when or in what order locals go out of scope in sync code unless compiler starts complaining. And it seems OK to mostly not care because everything's going to be dropped shortly. I imagine other people might have the same attitude.
With locals being held across yield points in async methods, it might turn out to be much more problematic. While there are cases when you'd get reminded quickly (e.g. !Send
local in Future + Send
) Notable mishaps that I can imagine:
- unnecessarily holding on to response data from after first await that was used to create next request. People don't really want to hold on to something they don't need. Especially if it's a few KBs in size and future will not complete for another minute. And there's 5K futures / sec like that.
- taking lock and mistakenly thinking that it's released. I think it is rare to need to lock across yield points.
- generally assuming drop will happen at yield point and planning logic with that in mind.