event/PollGroupWinSelect: add Item constructor

This commit is contained in:
Max Kellermann 2020-10-09 17:50:34 +02:00
parent 69b45e693b
commit b0282fe36f
2 changed files with 11 additions and 8 deletions

View File

@ -64,14 +64,11 @@ bool
WinSelectBackend::Add(SOCKET fd, unsigned events, void *obj) noexcept
{
assert(items.find(fd) == items.end());
auto i = items.emplace(fd, Item{}).first;
auto i = items.emplace(std::piecewise_construct,
std::forward_as_tuple(fd),
std::forward_as_tuple(obj)).first;
auto &item = i->second;
item.index[EVENT_READ] = -1;
item.index[EVENT_WRITE] = -1;
item.obj = obj;
item.events = 0;
if (!CanModify(item, events, EVENT_READ)) {
items.erase(i);
return false;

View File

@ -91,9 +91,15 @@ class WinSelectBackend
{
struct Item
{
int index[2];
int index[2]{-1, -1};
void *obj;
unsigned events;
unsigned events = 0;
explicit constexpr Item(void *_obj) noexcept
:obj(_obj) {}
Item(const Item &) = delete;
Item &operator=(const Item &) = delete;
};
SocketSet event_set[2];