cogciprocate / ocl

OpenCL for Rust
Other
731 stars 75 forks source link

New Pin type could be used to make BufferBuilder::use_host_slice safe(r)? #139

Open dmarcuse opened 5 years ago

dmarcuse commented 5 years ago

Rust 1.33 was just released, and one of the new features is the Pin<T> type, which prevents a value from being moved in memory. This could be useful when using buffers with the CL_USE_HOST_PTR flag. I think it could even be made 100% safe (on the Rust side of things at least) by also adding a lifetime restriction to the Buffer itself so that the reference is forced to live at least as long as the underlying OpenCL buffer.

c0gent commented 5 years ago

Yeah I think you might be right. I'd like to spend some time on this but I might not be able to for a while. I've been waiting for Pin for about two years for some other async related stuff and I might try to do that first (add it to the todo list...).

If you end up playing around with it, let me know what you find.