New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
将AsyncDrop从AbortSafeFuture中拆分出来 #1
base: master
Are you sure you want to change the base?
Conversation
我还没想明白的是:
unsafe fn poll_drop(self: *mut self, cx: &mut Context) -> Poll<()>;
|
d06f53f
to
6da00e1
Compare
3 的话,感觉不需要严格约定到 AbortSafeFuture 的实现?我理解其实这些 blanket impl 算是实现的一部分,只约定 AbortSafeFuture 对外表现的行为是符合 poll 之后 poll_drop 的就行了( |
1 需要+1,poll 已经要求手动 drop = 跟 AsyncDrop 是绑定的;另外 AsyncDrop 有单独抽出来的必要吗( |
2 个人感觉不引入 unsafe 更好一点( |
对于普通Future应该也能用这个trait,可以根据某个flag决定是否用AsyncDrop。 |
另外,AsyncDrop 的名字给人的感觉更像是异步的析构 |
确实就是。通过异步的析构来中断Future,而不是同步的析构 |
我的意思是, |
感觉有普适性?毕竟异步析构也是类这样的API,同时这里通过ManuallyDrop包裹了一下,实现了异步析构就不能安全地进行同步的析构了。 |
之前
AbortSafeFuture
中,poll
和poll_cancel
里面都需要有内存释放的逻辑。可以单独抽离一个
AsyncDrop
trait来统一内存释放的逻辑。而中断Future的逻辑也有
AsyncDrop
承担。