Skip to content
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

Suggestion for mapped relink() fallback on windows #132

Open
patstew opened this issue Jun 12, 2024 · 2 comments
Open

Suggestion for mapped relink() fallback on windows #132

patstew opened this issue Jun 12, 2024 · 2 comments

Comments

@patstew
Copy link
Contributor

patstew commented Jun 12, 2024

Currently the docs for mapped_file_handle say:

You are guaranteed on Windows only that `address()` will not return a new value unless:
...
4. You call `relink()`, which requires closing and reopening the map because you cannot
rename a file with an open map on Windows.

which is true, but what you can do is link+unlink it which has almost the same effect, except you can't reuse the old filename until you release the handle. Might be a useful fallback for mapped_file_handle::relink and/or relink_or_clone_copy_unlink? It's useful, at least to me, to be able to rename a mapped file without changing address or having to copy the whole thing.

@ned14
Copy link
Owner

ned14 commented Jun 12, 2024

To be clear, you're suggesting that instead of renaming the file with an open map, you just keep adding hard links until when you eventually tear down the map and close the file, all the links now marked delete on close will get cleaned up?

@patstew
Copy link
Contributor Author

patstew commented Jun 12, 2024

Yes, basically. Though I was only thinking about doing it once. I haven't thought through all the implications, In my case I create a temporary file which the user can choose to save later on, and with this workaround I can avoid waiting for all my threads to stop looking at the map so I can relink it, or having to copy it, for the sake of windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants