StephanvanSchaik / mmap-rs

A cross-platform and safe Rust API to create and manage memory mappings in the virtual address space of the calling process.
Apache License 2.0
61 stars 17 forks source link

impl of `Send` and `Sync` #5

Closed TimLuq closed 1 year ago

TimLuq commented 1 year ago

In my use case I wanted to open a file based mmap in a dedicated IO thread and then send it over to another thread when the mapping was complete. I am unable to think of any reason why Send and Sync wouldn't be allowed for Mmap.

My guess is that it's simply an oversight and the compiler's autotrait is wrong due to the raw pointer ptr only referring to a memory location accessible process wide which the compiler does not know. If that is the case unsafe impls should be added for Send and Sync in each of the os_impls.

I'll create a PR for this in case you want to merge it.