event/PollBackend: add Item constructor

This commit is contained in:
Max Kellermann 2020-10-30 16:31:39 +01:00
parent b9b02b4ff2
commit b1b731340e
2 changed files with 9 additions and 4 deletions

View File

@ -36,10 +36,9 @@ PollBackend::Add(int fd, unsigned events, void *obj) noexcept
e.events = events; e.events = events;
e.revents = 0; e.revents = 0;
auto i = items.emplace(fd, Item{}).first; items.emplace(std::piecewise_construct,
auto &item = i->second; std::forward_as_tuple(fd),
item.index = index; std::forward_as_tuple(index, obj));
item.obj = obj;
return true; return true;
} }

View File

@ -34,6 +34,12 @@ class PollBackend
{ {
std::size_t index; std::size_t index;
void *obj; void *obj;
constexpr Item(std::size_t _index, void *_obj) noexcept
:index(_index), obj(_obj) {}
Item(const Item &) = delete;
Item &operator=(const Item &) = delete;
}; };
std::vector<pollfd> poll_events; std::vector<pollfd> poll_events;