// File: guoxuanhan[P]NetServer/tcpserver.cpp
// Function: TcpServer::TcpServer(EventLoop*, int, int)
TcpServer::TcpServer(EventLoop* loop, const int port, const int threadnum)
    : serversocket_(),
    loop_(loop),
    serverchannel_(),
    conncount_(0),
    eventloopthreadpool(loop, threadnum)
{
    //serversocket_.SetSocketOption();
    serversocket_.SetReuseAddr();
    serversocket_.BindAddress(port);
    serversocket_.Listen();
    serversocket_.Setnonblocking();

    serverchannel_.SetFd(serversocket_.fd());
    serverchannel_.SetReadHandle(std::bind(&TcpServer::OnNewConnection, this));
    serverchannel_.SetErrorHandle(std::bind(&TcpServer::OnConnectionError, this));

}

// Assembly:
subq $0x138, %rsp            # imm = 0x138
movq %rdi, 0x130(%rsp)
movq %rsi, 0x128(%rsp)
movl %edx, 0x124(%rsp)
movl %ecx, 0x120(%rsp)
movq 0x130(%rsp), %rdi
movq %rdi, 0x60(%rsp)
movq %rdi, %rax
movq %rax, 0x58(%rsp)
callq 0x1b990
movq 0x60(%rsp), %rdi
movq 0x128(%rsp), %rax
movq %rax, 0x8(%rdi)
addq $0x10, %rdi
movq %rdi, 0x68(%rsp)
callq 0x5bc0
jmp 0x1f1f0
movq 0x58(%rsp), %rdi
movl $0x0, 0x98(%rdi)
addq $0xa0, %rdi
movq %rdi, 0x48(%rsp)
callq 0x1fb70
movq 0x58(%rsp), %rdi
addq $0xd0, %rdi
callq 0x8970
movq 0x58(%rsp), %rdi
addq $0xf8, %rdi
movq %rdi, 0x50(%rsp)
movq 0x128(%rsp), %rsi
movl 0x120(%rsp), %edx
callq 0xb220
jmp 0x1f248
movq 0x58(%rsp), %rdi
addq $0x128, %rdi            # imm = 0x128
movq %rdi, 0x20(%rsp)
callq 0x1d390
movq 0x58(%rsp), %rdi
addq $0x148, %rdi            # imm = 0x148
movq %rdi, 0x28(%rsp)
callq 0x1d350
movq 0x58(%rsp), %rdi
addq $0x168, %rdi            # imm = 0x168
movq %rdi, 0x30(%rsp)
callq 0x1d390
movq 0x58(%rsp), %rdi
addq $0x188, %rdi            # imm = 0x188
movq %rdi, 0x38(%rsp)
callq 0x1d390
movq 0x58(%rsp), %rdi
addq $0x1a8, %rdi            # imm = 0x1A8
movq %rdi, 0x40(%rsp)
callq 0x1d390
movq 0x58(%rsp), %rdi
callq 0x1ba80
jmp 0x1f2c2
movq 0x58(%rsp), %rdi
movl 0x124(%rsp), %esi
callq 0x1bb60
jmp 0x1f2d5
movq 0x58(%rsp), %rdi
callq 0x1bc20
jmp 0x1f2e1
movq 0x58(%rsp), %rdi
callq 0x1bac0
jmp 0x1f2ed
movq 0x58(%rsp), %rdi
movq %rdi, %rax
addq $0x10, %rax
movq %rax, 0x10(%rsp)
callq 0x1fb80
movl %eax, 0x1c(%rsp)
jmp 0x1f309
movl 0x1c(%rsp), %esi
movq 0x10(%rsp), %rdi
callq 0x5c70
jmp 0x1f319
movq 0x58(%rsp), %rax
movq %rax, %rcx
addq $0x10, %rcx
movq %rcx, 0x8(%rsp)
leaq 0x1ef(%rip), %rcx       # 0x1f520
movq %rcx, 0xc8(%rsp)
movq $0x0, 0xd0(%rsp)
movq %rax, 0xc0(%rsp)
leaq 0xd8(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
leaq 0xc0(%rsp), %rdx
callq 0x1fb90
jmp 0x1f36c
leaq 0xf0(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x1fbd0
jmp 0x1f383
movq 0x8(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x5df0
jmp 0x1f397
leaq 0xf0(%rsp), %rdi
callq 0x5ef0
movq 0x58(%rsp), %rax
movq %rax, %rcx
addq $0x10, %rcx
movq %rcx, (%rsp)
leaq 0x4b5(%rip), %rcx       # 0x1f870
movq %rcx, 0x78(%rsp)
movq $0x0, 0x80(%rsp)
movq %rax, 0x70(%rsp)
leaq 0x88(%rsp), %rdi
leaq 0x78(%rsp), %rsi
leaq 0x70(%rsp), %rdx
callq 0x1fb90
jmp 0x1f3ea
leaq 0xa0(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x1fbd0
jmp 0x1f401
movq (%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x5e50
jmp 0x1f414
leaq 0xa0(%rsp), %rdi
callq 0x5ef0
addq $0x138, %rsp            # imm = 0x138
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x118(%rsp)
movl %eax, 0x114(%rsp)
jmp 0x1f505
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x118(%rsp)
movl %eax, 0x114(%rsp)
jmp 0x1f4f1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x118(%rsp)
movl %eax, 0x114(%rsp)
jmp 0x1f4b5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x118(%rsp)
movl %eax, 0x114(%rsp)
leaq 0xf0(%rsp), %rdi
callq 0x5ef0
jmp 0x1f4b5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x118(%rsp)
movl %eax, 0x114(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x5ef0
movq 0x40(%rsp), %rdi
callq 0x68c0
movq 0x38(%rsp), %rdi
callq 0x68c0
movq 0x30(%rsp), %rdi
callq 0x68c0
movq 0x28(%rsp), %rdi
callq 0x6a00
movq 0x20(%rsp), %rdi
callq 0x68c0
movq 0x50(%rsp), %rdi
callq 0xb320
movq 0x48(%rsp), %rdi
callq 0x1fc80
movq 0x68(%rsp), %rdi
callq 0x5c20
movq 0x60(%rsp), %rdi
callq 0x1ba10
movq 0x118(%rsp), %rdi
callq 0x5660
nopl (%rax)