event/PollGroupWinSelect: add Item constructor
This commit is contained in:
parent
69b45e693b
commit
b0282fe36f
@ -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;
|
||||
|
@ -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];
|
||||
|
Loading…
Reference in New Issue
Block a user