On 6/16/25 12:56 PM, Iain Sandoe wrote:
+ 0 signalling that both the body and the ramp have completed (i.e. the body
+ ran to completion before the ramp was re-entered).
I had figured that the ramp would set the reference count to 1 initially, and
decrement it in a cleanup, and the actor would increment it after initial
await_resume, and decrement after final_suspend.
<snip>
As we then discussed off-list, the idea is then that the ramp has
a cleanup around the call to the body and the construction of the
return (where appropriate). We then need the body to increment
the count when it has a use of the frame - but that use needs to be
released when an exception occurs before initial await_suspend. The
idea is to implement that with an eh-only cleanup around the
initial expressions.
When I came to implement this - it turned out to need a small tweak;
since we cannot sub-divide the await expression the cleanup needs
to be extended to encompass the initial await and the body.
I don't follow. Why does indivisibility mean it can't just encompass
the (entire) initial_await?
In the
case that i_a_r_c is false we then expect the ramp to cleanup and
the body has released its use.
However, once i_a_r_c is passed, the body needs to reclaim its
use, since if unhanded_exception throws, the ramp must not clean
up - instead the user must do handle.destroy(). If u_h_e does not
throw then we continue with the final-await expression and the
body use is still relevant. The solution to this is to increment
the use before calling promise.unhanded_exception().
I expected that the body cleanup would check iarc and not do the
decrement if iarc is true. I guess your approach is semantically
equivalent if the cleanup covers the whole body, but wouldn't work if it
just surrounds the initial await.
Jason