-
Notifications
You must be signed in to change notification settings - Fork 172
Expose a low-level API in lib.rs #20
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
Comments
Are you asking for
This is already possible. |
Yep, Then if the Mmap structure is not much larger than the size of a pointer, I'd be happy. |
I'm not against adding |
I definitely understand and respect the purpose of your crate, which is why I initially planned to call mmap directly from my crate.
|
The issue is that you are returning the same type, and so it must have the same destructor. There is no way to handle destruction safely at that point without either having the offset in the |
Also if it does show up, you could add a fast path for when the offset is 0 in the constructor function. Still no way to remove the check from the destructor, though. Again, none of this matters in the grand scheme of how expensive it is to create a mmap. |
Right! Which, I realize now, is why I was also asking to call munmap myself! I store the offset in a struct in my crate. I'd be happy to have even a really unsafe function, returning a raw pointer that I need to munmap myself. My main constraint is portability. |
Hmm OK I'm not seeing the issue. I've quickly skimmed the code in http://pijul.org/sanakirja/src/transaction.rs, but I can't see why you wouldn't be able to use |
Ok, I can try. The thing I want is not yet implemented in Sanakirja, I wanted to map stuff in a way that might not be too portable. I see how I could use you stuff with just the support for |
Not sure if I should add to this issue or make another, let me know if you'd rather I move this to another one. I also need some low-level control for a library I am working on; in particular, I need:
Like @pijul I would also like the option to do all page alignment checks myself. I think the best way to accomplish these goals is to expose another |
,
Yah, I think
I don't think this is possible on Windows, from reading the UnmapViewOfFile docs. Not sure what your usecase is, but perhaps it would be enough to
The goal of this crate has been to expose the lowest common denominator interface that works across platform. The support for non-page aligned offsets is pretty much the only 'feature' provided that doesn't map 1 to 1 with a system call, and that's because it is essentially zero overhead to provide it. |
Ah, you're right about |
Alright, I've found a workaround and changed my API for something simpler. I know I should use views for what I want to do, but the API is a bit too complex for my use case (i'm basically writing a concurrent allocator of pages in an mmaped file). |
@pijul that's an interesting usecase that tends to come up a lot. It was the reason I added the unsafe clone to the view type (so I could unsafely clone the view, and then flush from another thread). Perhaps flush shouldn't require a mutable borrow of the |
You're right, it's actually not unsafe, since it doesn't change anything to the program's memory. Even if the mmap is mutable borrowed in the same lifetime, it doesn't change the contents of the borrows. |
Just published version 0.3 with flush methods taking a const reference. I'm created #21 to track the |
I'd love to use this library, but currently it's doing too much for my particular use case.
In particular, I'd like to:
The text was updated successfully, but these errors were encountered: