Skip to content

Commit f787413

Browse files
committed
Enable BpfMap to be shared, add get_parent
1 parent b4d0a49 commit f787413

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/core/bpf_map.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class BpfObject;
1515

1616
namespace py = pybind11;
1717

18-
class BpfMap {
18+
class BpfMap : public std::enable_shared_from_this<BpfMap> {
1919
private:
2020
std::weak_ptr<BpfObject> parent_obj_;
2121
struct bpf_map *map_;
@@ -62,6 +62,9 @@ class BpfMap {
6262
[[nodiscard]] int get_key_size() const { return key_size_; };
6363
[[nodiscard]] int get_value_size() const { return value_size_; };
6464
[[nodiscard]] int get_max_entries() const;
65+
[[nodiscard]] std::shared_ptr<BpfObject> get_parent() const {
66+
return parent_obj_.lock();
67+
}
6568

6669
private:
6770
static void python_to_bytes_inplace(const py::object &obj,

0 commit comments

Comments
 (0)