geopm 3.1.1.dev456+g3ba31824
GEOPM - Global Extensible Open Power Manager
Loading...
Searching...
No Matches
IOUringImp.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015 - 2024 Intel Corporation
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#ifndef IOURINGIMP_HPP_INCLUDE
7#define IOURINGIMP_HPP_INCLUDE
8
9#ifndef _DEFAULT_SOURCE
10// Liburing uses some typedefs gated by _DEFAULT_SOURCE
11#define _DEFAULT_SOURCE
12#endif
13#include <liburing.h>
14
15#include "IOUring.hpp"
16
17#include <vector>
18
19namespace geopm
20{
23 class IOUringImp final : public IOUring
24 {
25 public:
26 IOUringImp(unsigned entries);
27 virtual ~IOUringImp();
28 IOUringImp(const IOUringImp &other) = delete;
29 IOUringImp &operator=(const IOUringImp &other) = delete;
30
31 void submit() override;
32
33 void prep_read(std::shared_ptr<int> ret, int fd,
34 void *buf, unsigned nbytes, off_t offset) override;
35
36 void prep_write(std::shared_ptr<int> ret, int fd,
37 const void *buf, unsigned nbytes, off_t offset) override;
38
40 static bool is_supported();
41
45 static std::unique_ptr<IOUring> make_unique(unsigned entries);
46 protected:
47 struct io_uring_sqe *get_sqe_or_throw();
49 struct io_uring_sqe *sqe,
50 std::shared_ptr<int> destination);
51
52 private:
53 struct io_uring m_ring;
54 std::vector<std::shared_ptr<int> > m_result_destinations;
55 };
56}
57#endif // IOURINGIMP_HPP_INCLUDE
Definition IOUring.hpp:18
Implementation of the IOUring batch interface. This implementation batches operations inside io_uring...
Definition IOUringImp.hpp:24
IOUringImp(const IOUringImp &other)=delete
void prep_read(std::shared_ptr< int > ret, int fd, void *buf, unsigned nbytes, off_t offset) override
Perform a pread in the next batch submission.
Definition IOUringImp.cpp:86
static std::unique_ptr< IOUring > make_unique(unsigned entries)
Create an IO uring with queues of a given size.
Definition IOUringImp.cpp:123
IOUringImp & operator=(const IOUringImp &other)=delete
void prep_write(std::shared_ptr< int > ret, int fd, const void *buf, unsigned nbytes, off_t offset) override
Perform a pwrite in the next batch submission.
Definition IOUringImp.cpp:95
void submit() override
Submit all prepared uring operations in a batch, and wait for all operations to return a result....
Definition IOUringImp.cpp:57
struct io_uring_sqe * get_sqe_or_throw()
Definition IOUringImp.cpp:34
static bool is_supported()
Return whether this implementation of IOUring is supported.
Definition IOUringImp.cpp:104
virtual ~IOUringImp()
Definition IOUringImp.cpp:29
void set_sqe_return_destination(struct io_uring_sqe *sqe, std::shared_ptr< int > destination)
Definition IOUringImp.cpp:44
Definition Agg.cpp:20