mirror of
https://github.com/vimpunk/mio.git
synced 2025-12-06 16:57:01 +08:00
Update README.md
This commit is contained in:
parent
dcdfacefb2
commit
8c783cf92d
@ -6,7 +6,9 @@ mio has been created with the goal to be easily includable (i.e. no dependencies
|
||||
Please feel free to open an issue, I'll try to address any concerns as best I can.
|
||||
|
||||
### Why?
|
||||
The primary motivation for writing this library instead of using Boost.Iostreams, was the lack of support for establishing a memory mapping with an already open file handle/descriptor. This is possible with mio.
|
||||
Because memory mapping is the best thing since sliced bread!
|
||||
|
||||
More seriously, the primary motivation for writing this library instead of using Boost.Iostreams, was the lack of support for establishing a memory mapping with an already open file handle/descriptor. This is possible with mio.
|
||||
|
||||
Albeit a minor nitpick, Boost.Iostreams implements memory mapped file IO with a `std::shared_ptr` to provide shared semantics, even if not needed, and the overhead of the heap allocation may be unnecessary and/or unwanted.
|
||||
In mio, there are two classes to cover the two use-cases: one that is move-only (basically a zero-cost abstraction over the system specific mmapping functions), and the other that acts just like its Boost.Iostreams counterpart, with shared semantics.
|
||||
@ -48,7 +50,7 @@ int main()
|
||||
// ...
|
||||
}
|
||||
```
|
||||
However, mio does not check whether the provided file descriptor has the same access permissions as the desired mapping, so the mapping may fail.
|
||||
However, mio does not check whether the provided file descriptor has the same access permissions as the desired mapping, so the mapping may fail. Such errors are reported via the `std::error_code` out parameter that is passed to the mapping function.
|
||||
|
||||
### Example
|
||||
```c++
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user