Expand description
§An FFI interface for WinMMF
The recommended way of working with this interface is to call open (or new) and then immediately read
with an explicit count of 0. Reuse the pointer provided for all subsequent reads by calling read_buf, and then
freeing it with free_result, most likely with other teardown and exit steps for your program. Alternatively, you
could just bring your own pointers. Just make sure they’re all valid.
If the lifetime for any MMFs should be &'static or longer than the execution context (e.g. you only open MMFs
created by a system service), it’s possible to leave cleanup to the OS. No guarantees are made if or when that
happens, other than that cleanup will be done between program exit and system shutdown. If nobody is using the MMF
anymore, and all relevant programs have finished their main function (regardless of exit status), the system
should free up lingering handles with no active processes before erroring on the resource limit getting hit.
During the lifetime of your program, if you decide to close any MMFs, they will be ejected from the inner
collection. Should you need to reopen one, and you’re sure other handles to it yet live in the system, you can open
it anew and your data should be there unchanged.
Should you forget to free a pointer, use free_raw at your own risk.
If you need to use several MMFs at once in your code, you can. Beware that tracking their indices is entirely at
your own risk though. Should you know which indices you need, and do you plan to use the same one for extended
periods of time, then select one for use with select_default.
Enums§
- Valid
Namespaces - Namespaces as an enum, to unambiguously represent relevant information.
Functions§
- close
- Close the MMF
- free_
raw ⚠ - You had better know how big that thing is.
- free_
result ⚠ - Free a pointer used for reading from an MMF by its index number.
- init
- Initialize the inner object to hold MMF instances.
- new
- Create a new MMF and push it into the list, returning the new index or an error indicator.
- open
- Open an existing MMF and push it into the list, returning its index or an error indicator.
- open_ro
- Convenience function to open a read-only MMF and get an index back to read from it.
- read
- Read
countbytes or all contents from the MMF and give back a pointer to the data. - read_
buf ⚠ - Read
countbytes from the MMF into the provided buffer. - select_
default - Selects a different default mmf for all operations.
- write⚠
- Expose writing data as well. Slightly less complex for FFI purposes than reading.