Closed defiori closed 3 years ago
Hi, thanks a lot for the PR.
I will try to review it and fix the build issues in the next couple of days
Sounds good, thanks. The latest commit fixes clippy's complaints on Windows, the remaining build issue isn't specific to this PR.
Thanks again for the PR.
I have converted your code to rely on std as much as it could and merged it into master.
I will publish a new version of the crate (0.12.X) in the next couple of days.
Let me know if you spot any issues with my refactoring ;)
This looks much cleaner, thanks. I just added one minor nitpick in a comment, otherwise it looks good. Looking forward to v0.12!
Shmem
currently behaves differently on Windows than Unix. Specifically,Shmem::set_owner
has no effect on the underlying memory object on Windows, as the standard Windows shared file mapping doesn't allow persistence. This means that dropping a uniqueShmem
will destroy the shared memory even whenShmem::is_owner
returns false. This clashes with POSIX behaviour, which persists the memory unlessshm_unlink()
is called and allows reopening even when all handles have previously been closed.This PR unifies shared memory behaviour on Windows and Unix and adds a test to check for compliance. It follows the C++ Boost implementation of creating a file to back the shared memory which is renamed and marked for deletion when an owning
Shmem
drops, but persists otherwise.Shmem::set_owner
stops being a no-op on Windows and now behaves as expected.