// Since cuda memcpys in streams are async, this gets a bit tricky.
lethost_clone=this.host.clone();
// We can't just consume the queue normally, otherwise the stream would become very backlogged.
letdisk_clone=this.disk.clone();
// From the point when the a transfer is put into the stream until the transfer corresponding to the block is complete, we need to hold a strong reference to the block.
lettransfer_ctx_clone=transfer_ctx.clone();
// If we don't do this, the block may be evicted and overwritten before the transfer is complete.
async_rt_handle.spawn(asyncmove{
// To do this, we use a queue to track blocks currently being offloaded. Once the offload is complete (as indicated by a CudaEvent), the reference to the block is dropped.