MCPcopy Create free account
hub / github.com/CodingGay/BlackDex / unique_fd_impl

Class unique_fd_impl

Bcore/src/main/cpp/android-base/unique_fd.h:60–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58
59template <typename Closer>
60class unique_fd_impl final {
61 public:
62 unique_fd_impl() : value_(-1) {}
63
64 explicit unique_fd_impl(int value) : value_(value) {}
65 ~unique_fd_impl() { reset(); }
66
67 unique_fd_impl(unique_fd_impl&& other) : value_(other.release()) {}
68 unique_fd_impl& operator=(unique_fd_impl&& s) {
69 reset(s.release());
70 return *this;
71 }
72
73 void reset(int new_value = -1) {
74 if (value_ != -1) {
75 Closer::Close(value_);
76 }
77 value_ = new_value;
78 }
79
80 int get() const { return value_; }
81 operator int() const { return get(); }
82
83 int release() __attribute__((warn_unused_result)) {
84 int ret = value_;
85 value_ = -1;
86 return ret;
87 }
88
89 private:
90 int value_;
91
92 unique_fd_impl(const unique_fd_impl&);
93 void operator=(const unique_fd_impl&);
94};
95
96using unique_fd = unique_fd_impl<DefaultCloser>;
97

Callers

nothing calls this directly

Calls 1

releaseMethod · 0.45

Tested by

no test coverage detected