Emulate POSIX shared memory behavior on Windows #59
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.