21 #include <kvikio/defaults.hpp>
22 #include <kvikio/file_handle.hpp>
41 std::size_t _initial_map_size{};
42 std::size_t _initial_map_offset{};
43 std::size_t _file_size{};
44 std::size_t _map_offset{};
45 std::size_t _map_size{};
48 int _map_protection{};
65 std::size_t validate_and_adjust_read_args(std::optional<std::size_t>
const& size,
91 std::
string const& flags = "r",
95 std::optional<
int> map_flags = std::nullopt);
131 [[nodiscard]] std::
size_t nbytes() const;
138 [[nodiscard]]
bool closed() const noexcept;
161 std::optional<std::
size_t> size = std::nullopt,
162 std::
size_t offset = 0);
183 std::future<std::
size_t>
pread(
void* buf,
184 std::optional<std::
size_t> size = std::nullopt,
185 std::
size_t offset = 0,
186 std::
size_t task_size =
defaults::task_size());
Handle of an open file registered with cufile.
Class that provides RAII for file handling.
Handle of a memory-mapped file.
std::size_t read(void *buf, std::optional< std::size_t > size=std::nullopt, std::size_t offset=0)
Sequential read size bytes from the file (with the offset offset) to the destination buffer buf
std::future< std::size_t > pread(void *buf, std::optional< std::size_t > size=std::nullopt, std::size_t offset=0, std::size_t task_size=defaults::task_size())
Parallel read size bytes from the file (with the offset offset) to the destination buffer buf
bool closed() const noexcept
Whether the mapping handle is closed.
std::size_t file_size() const
Get the file size if the file is open. Returns 0 if the file is closed.
void close() noexcept
Close the mapping handle if it is open; do nothing otherwise.
std::size_t nbytes() const
Alias of file_size
std::size_t initial_map_offset() const noexcept
File offset of the mapped region when the mapping handle was constructed.
MmapHandle() noexcept=default
Construct an empty memory-mapped file.
std::size_t initial_map_size() const noexcept
Size in bytes of the mapped region when the mapping handle was constructed.
Singleton class of default values used throughout KvikIO.