// File: JianjiaoSQ[P]MyPoorWebServer/././threadpool/threadpool.h
// Function: threadpool<http_conn>::threadpool(int, connection_pool*, int, int)
threadpool<T>::threadpool( int actor_model, connection_pool *connPool, int thread_number, int max_requests) : m_actor_model(actor_model),m_thread_number(thread_number), m_max_requests(max_requests), m_threads(NULL),m_connPool(connPool)
{
    if (thread_number <= 0 || max_requests <= 0)
        throw std::exception();
    m_threads = new pthread_t[m_thread_number];
    if (!m_threads)
        throw std::exception();
    for (int i = 0; i < thread_number; ++i)
    {
        if (pthread_create(m_threads + i, NULL, worker, this) != 0)
        {
            delete[] m_threads;
            throw std::exception();
        }
        if (pthread_detach(m_threads[i]))
        {
            delete[] m_threads;
            throw std::exception();
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x40(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, (%rdi)
movl -0x20(%rbp), %eax
movl %eax, 0x4(%rdi)
movq $0x0, 0x8(%rdi)
addq $0x10, %rdi
movq %rdi, -0x48(%rbp)
callq 0xcf10
movq -0x40(%rbp), %rdi
addq $0x28, %rdi
movq %rdi, -0x38(%rbp)
callq 0x6d30
jmp 0xc8e8
movq -0x40(%rbp), %rdi
addq $0x50, %rdi
movq %rdi, -0x50(%rbp)
callq 0xa490
jmp 0xc8fb
movq -0x40(%rbp), %rax
movq -0x18(%rbp), %rcx
movq %rcx, 0x70(%rax)
movl -0xc(%rbp), %ecx
movl %ecx, 0x78(%rax)
cmpl $0x0, -0x1c(%rbp)
jle 0xc919
cmpl $0x0, -0x20(%rbp)
jg 0xc987
movl $0x8, %edi
callq 0x3200
movq %rax, %rdi
movq %rdi, -0x58(%rbp)
callq 0x7300
movq -0x58(%rbp), %rdi
movq 0x769e(%rip), %rsi      # 0x13fd8
movq 0x76af(%rip), %rdx      # 0x13ff0
callq 0x36f0
jmp 0xcb1a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0xcb08
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0xcaff
movq -0x50(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0xa5b0
jmp 0xcaff
movq -0x40(%rbp), %rax
movslq (%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x3030
movq %rax, -0x60(%rbp)
jmp 0xc9af
movq -0x40(%rbp), %rax
movq -0x60(%rbp), %rcx
movq %rcx, 0x8(%rax)
cmpq $0x0, 0x8(%rax)
jne 0xc9f4
movl $0x8, %edi
callq 0x3200
movq %rax, %rdi
movq %rdi, -0x68(%rbp)
callq 0x7300
movq -0x68(%rbp), %rdi
movq 0x75f5(%rip), %rsi      # 0x13fd8
movq 0x7606(%rip), %rdx      # 0x13ff0
callq 0x36f0
jmp 0xcb1a
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0xcaf6
movq -0x40(%rbp), %rcx
movq 0x8(%rcx), %rdi
movslq -0x30(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
leaq 0x50b(%rip), %rdx       # 0xcf30
callq 0x3780
cmpl $0x0, %eax
je 0xca7c
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x70(%rbp)
cmpq $0x0, %rax
je 0xca4a
movq -0x70(%rbp), %rdi
callq 0x35c0
movl $0x8, %edi
callq 0x3200
movq %rax, %rdi
movq %rdi, -0x78(%rbp)
callq 0x7300
movq -0x78(%rbp), %rdi
movq 0x756d(%rip), %rsi      # 0x13fd8
movq 0x757e(%rip), %rdx      # 0x13ff0
callq 0x36f0
jmp 0xcb1a
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x3350
cmpl $0x0, %eax
je 0xcae6
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x80(%rbp)
cmpq $0x0, %rax
je 0xcab1
movq -0x80(%rbp), %rdi
callq 0x35c0
movl $0x8, %edi
callq 0x3200
movq %rax, %rdi
movq %rdi, -0x88(%rbp)
callq 0x7300
movq -0x88(%rbp), %rdi
movq 0x7500(%rip), %rsi      # 0x13fd8
movq 0x7511(%rip), %rdx      # 0x13ff0
callq 0x36f0
jmp 0xcb1a
jmp 0xcae8
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0xc9fb
addq $0x90, %rsp
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0x6d90
movq -0x48(%rbp), %rdi
callq 0xcca0
movq -0x28(%rbp), %rdi
callq 0x3710
nopw (%rax,%rax)