I can't understand how using split_at() would work...if the CPU and the GPU both have a reference to the RAM, we're still using an Rc<RefCell<>>. If the slice gets passed into the CPU and GPU's run() functions, then how does this magical memory manager know what to pass ahead of time?
>It's hard to implement unsafe patterns in safe language.
I agree with this 100%. And I think that for certain problem domains, rust provides more safety than you actually want.
Split memory into pages. Then create two types: OwnedMem, and SharedMem. OwnedMem will own page(s), so access to memory will require no Arc. SharedMem will implement safe protocol to access memory from different threads using Arc or atomic operations. SharedMem must also implement .clone(), so both CPU and GPU will be able to hold it.
> And I think that for certain problem domains, rust provides more safety than you actually want.
If writing of unsafe Rust by hands is hard for you, then write code in plain C, then convert it into unsafe Rust using crust.
>It's hard to implement unsafe patterns in safe language.
I agree with this 100%. And I think that for certain problem domains, rust provides more safety than you actually want.