-
Notifications
You must be signed in to change notification settings - Fork 73
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
Using MmapMut from multiple threads for simultaneous writing #36
Comments
If you can guarantee this within your application, you should be able to start from a single But essentially, if you start from a single |
As a further illustration of the above even though it might not be helpful for your use case: As the byte slice provided by |
@adamreichold thank you for your quick reply!!! I'm still new to Rust (fun to learn it though!), so I might need a bit more guidance. Could you show a simple example (maybe even later add it to the docs?) that demonstrates how I can do this? Ideally this method should be usable from the P.S. A user has offered a somewhat different example -- but i cannot evaluate if that approach has merit or not (see code) |
The technique shown in https://stackoverflow.com/questions/33818141/how-do-i-pass-disjoint-slices-from-a-vector-to-different-threads is basically what I am suggesting. As written above, your could should start off with Also as written above, you will probably need to pass fn some_thread(ptr: *mut u8, pos: usize) {
// SAFETY: Only one thread will access the data at pos s.t. `val` will not alias any other references.
let val = unsafe { &mut *ptr.add(pos) };
...
} if you cannot use an existing chunking mechanism like (I don't think |
I posted a stackoverflow question -- looking for some help on how to use this library to write to a file from multiple threads without any synchronization. Re-posting it here for visibility in case the author (thx!) or someone from the wonderful community can help.
The text was updated successfully, but these errors were encountered: