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.revents = 0;
auto i = items.emplace(fd, Item{}).first;
auto &item = i->second;
item.index = index;
item.obj = obj;
items.emplace(std::piecewise_construct,
std::forward_as_tuple(fd),
std::forward_as_tuple(index, obj));
return true;
}

View File

@ -34,6 +34,12 @@ class PollBackend
{
std::size_t index;
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;