// File: /workspace/github_cpp_makefile_star2_O3/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, 0x20(%rsp)
movq %rdi, %r13
movl (%rdi), %edi
leaq 0x8(%r13), %rbx
movq 0x8(%r13), %rsi
movq 0x18(%r13), %rax
subq %rsi, %rax
shrq $0x2, %rax
imull $0xaaaaaaab, %eax, %edx # imm = 0xAAAAAAAB
movl $0x3e8, %ecx            # imm = 0x3E8
callq 0x4190
cmpl $-0x1, %eax
movl %eax, 0xc(%rsp)
je 0xb0dd
testl %eax, %eax
jle 0xb0e9
leaq 0x50(%r13), %r12
leaq 0x28(%r13), %rax
movq %rax, 0x18(%rsp)
movl 0xc(%rsp), %eax
movq %rax, 0x30(%rsp)
xorl %r14d, %r14d
movq %r13, 0x28(%rsp)
movq (%rbx), %rax
leaq (%r14,%r14,2), %rcx
movl (%rax,%rcx,4), %ebp
movq 0x4(%rax,%rcx,4), %rdi
movq %rdi, 0x10(%rsp)
callq 0x4bbe
movl %eax, %r15d
movq %r12, %rdi
callq 0x4480
testl %eax, %eax
jne 0xb16e
movq 0x30(%r13), %rax
testq %rax, %rax
je 0xb077
movq 0x18(%rsp), %rcx
xorl %edx, %edx
cmpl %r15d, 0x20(%rax)
setl %dl
cmovgeq %rax, %rcx
movq 0x10(%rax,%rdx,8), %rax
testq %rax, %rax
jne 0xb014
cmpq 0x18(%rsp), %rcx
je 0xb077
movq %rbx, %r13
movl 0x20(%rcx), %ebx
movq %r12, %rdi
callq 0x42a0
cmpl %ebx, %r15d
movq %r13, %rbx
movq 0x28(%rsp), %r13
jl 0xb07f
movq 0x10(%rsp), %rdi
movl %ebp, %esi
callq 0x4bc2
movq 0x20(%rsp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0xb0d1
movq 0x10(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0xb0c1
movq %r12, %rdi
callq 0x42a0
movl $0x11, %edx
movq 0xcf2d(%rip), %r15      # 0x17fb8
movq %r15, %rdi
leaq 0x5ebb(%rip), %rsi      # 0x10f50
callq 0x43a0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x4320
movsbl %al, %esi
movq %r15, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4240
incq %r14
cmpq 0x30(%rsp), %r14
jne 0xafda
jmp 0xb0e9
leaq 0x10(%rsp), %rdx
callq 0xb4dc
jmp 0xb0c1
leaq 0x5e5a(%rip), %rdi      # 0x10f3e
callq 0x42d0
movq 0x18(%r13), %rax
subq 0x8(%r13), %rax
shrq $0x2, %rax
imull $0xaaaaaaab, %eax, %eax # imm = 0xAAAAAAAB
movl 0xc(%rsp), %ebp
cmpl %eax, %ebp
jne 0xb15f
movq 0xceae(%rip), %r14      # 0x17fb8
leaq 0x5e51(%rip), %rsi      # 0x10f62
movl $0x7, %edx
movq %r14, %rdi
callq 0x43a0
movq %r14, %rdi
movl %ebp, %esi
callq 0x4580
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4320
movsbl %al, %esi
movq %r14, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4240
addl %ebp, %ebp
movslq %ebp, %rsi
movq %rbx, %rdi
callq 0xb3c2
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %edi
callq 0x4220
nop