// File: /workspace/github_cpp_makefile_star2_O1/guoxuanhan[P]NetServer/poller.cpp
// Function: Poller::poll(std::vector<Channel*, std::allocator<Channel*>>&)
void Poller::poll(ChannelList& activechannellist)
{
    int timeout = TIMEOUT;
    int nfds = epoll_wait(pollfd_, &*eventlist_.begin(), (int)eventlist_.capacity(), timeout);
    if(nfds == -1)
    {
        perror("epoll wait error!");
    }
    //std::cout<< "event num: " << nfds << std::endl;
    for(int i = 0; i < nfds; i++)
    {
        int events = eventlist_[i].events;
        Channel* pchannel = (Channel*)eventlist_[i].data.ptr;
        int fd = pchannel->GetFd();

        std::map<int, Channel*>::const_iterator iter;
        {
            std::lock_guard<std::mutex> lock(mutex_);
            iter = channelmap_.find(fd);
        }
        if(iter != channelmap_.end())
        {
            pchannel->SetEvents(events);
            activechannellist.push_back(pchannel);
        } else
        {
            std::cout<< "not find channel!" << std::endl;
        }
    }
    if(nfds == (int)eventlist_.capacity())
    {
        std::cout<< "resize:" << nfds << std::endl;
        eventlist_.resize(nfds * 2);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, 0x28(%rsp)
movq %rdi, %r14
movl (%rdi), %edi
movq 0x8(%r14), %rsi
movq 0x18(%r14), %rax
subq %rsi, %rax
shrq $0x2, %rax
imull $0xaaaaaaab, %eax, %edx # imm = 0xAAAAAAAB
movl $0x3e8, %ecx            # imm = 0x3E8
callq 0x4190
movl %eax, %ebx
cmpl $-0x1, %eax
je 0xb1ba
leaq 0x8(%r14), %rax
movq %rax, 0x18(%rsp)
movl %ebx, 0xc(%rsp)
testl %ebx, %ebx
jle 0xb133
leaq 0x50(%r14), %rax
movq %rax, 0x20(%rsp)
leaq 0x28(%r14), %r12
movl 0xc(%rsp), %eax
movq %rax, 0x30(%rsp)
xorl %r15d, %r15d
movq 0x18(%rsp), %rax
movq (%rax), %rax
leaq (%r15,%r15,2), %rcx
movl (%rax,%rcx,4), %ebx
movq 0x4(%rax,%rcx,4), %rdi
movq %rdi, 0x10(%rsp)
callq 0x4bbe
movl %eax, %ebp
movq 0x20(%rsp), %rdi
callq 0x4480
testl %eax, %eax
jne 0xb1cb
movq %r14, %r13
movq 0x30(%r14), %rcx
movq %r12, %rax
testq %rcx, %rcx
je 0xb086
movq %r12, %rax
xorl %edx, %edx
cmpl %ebp, 0x20(%rcx)
setl %dl
cmovgeq %rcx, %rax
movq 0x10(%rcx,%rdx,8), %rcx
testq %rcx, %rcx
jne 0xb070
movq %r12, %r14
cmpq %r12, %rax
je 0xb098
cmpl 0x20(%rax), %ebp
cmovlq %r12, %rax
movq %rax, %r14
movq 0x20(%rsp), %rdi
callq 0x42a0
cmpq %r12, %r14
je 0xb0d4
movq 0x10(%rsp), %rdi
movl %ebx, %esi
callq 0x4bc2
movq 0x28(%rsp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
movq %r13, %r14
je 0xb11b
movq 0x10(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0xb125
movl $0x11, %edx
movq 0xced8(%rip), %rbx      # 0x17fb8
movq %rbx, %rdi
leaq 0x5e76(%rip), %rsi      # 0x10f60
callq 0x43a0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4320
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4240
movq %r13, %r14
jmp 0xb125
leaq 0x10(%rsp), %rdx
callq 0xb536
incq %r15
cmpq 0x30(%rsp), %r15
jne 0xb02c
movq 0x18(%r14), %rax
subq 0x8(%r14), %rax
shrq $0x2, %rax
imull $0xaaaaaaab, %eax, %eax # imm = 0xAAAAAAAB
movl 0xc(%rsp), %ebp
cmpl %eax, %ebp
jne 0xb1ab
movq 0xce64(%rip), %rbx      # 0x17fb8
leaq 0x5e17(%rip), %rsi      # 0x10f72
movl $0x7, %edx
movq %rbx, %rdi
callq 0x43a0
movq %rbx, %rdi
movl %ebp, %esi
callq 0x4580
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4320
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4240
addl %ebp, %ebp
movslq %ebp, %rsi
movq 0x18(%rsp), %rdi
callq 0xb41e
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5d8d(%rip), %rdi      # 0x10f4e
callq 0x42d0
jmp 0xaffe
movl %eax, %edi
callq 0x4220