// File: /workspace/github_cpp_makefile_star2_O2/switch-st[P]SimpleThreadPool/test.cpp
// Function: main
int main(int argc, char** argv)
{
	cout << "type job pool" << endl;
    STJPool job_pool(10, 20);

    cout << "begin" << endl;
    for (int i = 0; i < 100; ++i)
	{
        A a;
        SJob job(&A::fa, &a, i);
        job_pool.add_job_block(job);
	}
	cout << "end" << endl;

	sleep(5);
	job_pool.stop();
	cout << "done" << endl;


	cout << endl << endl << endl;
	cout << "type function pool" << endl;
	STFPool func_pool;
	func_pool.SetMaxPoolSize(10);

    int num1 = 1;
    int* p1 = &num1;
    func_pool.AddThread(boost::bind(func1, (void*)p1));
    int num2 = 2;
    int* p2 = &num2;
    func_pool.AddThread(boost::bind(func1, (void*)p2));
    int num3 = 3;
    int* p3 = &num3;
    func_pool.AddThread(boost::bind(func1, (void*)p3));
    func_pool.AddThread(func2);

    while(1)
    {
        cout << "\t\t\tthread pool size = " << func_pool.GetPoolSize() << endl;
        if (func_pool.GetPoolSize() == 0)
        {
            break;
        }
        sleep(1);
    }

    func_pool.StopThreadPool();

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x248, %rsp            # imm = 0x248
movq 0xd8e7(%rip), %rbx      # 0x12fd0
leaq 0x594b(%rip), %rsi      # 0xb03b
movq %rbx, %rdi
callq 0x5230
movq %rax, %rdi
callq 0x50f0
leaq 0x68(%rsp), %rdi
pushq $0xa
popq %rsi
pushq $0x14
popq %rdx
callq 0x5a56
leaq 0x5932(%rip), %rsi      # 0xb049
movq %rbx, %rdi
callq 0x5230
movq %rax, %rdi
callq 0x50f0
xorl %ebx, %ebx
leaq 0x3ee(%rip), %r14       # 0x5b1e
leaq 0x18(%rsp), %r15
leaq 0xc(%rsp), %r12
leaq 0x68(%rsp), %r13
cmpl $0x64, %ebx
je 0x576e
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
movq %r12, %rcx
movl %ebx, %r8d
callq 0x5b54
movq %r13, %rdi
movq %r15, %rsi
callq 0x5be6
movq %r15, %rdi
callq 0x5c58
incl %ebx
jmp 0x573f
movq 0xd85b(%rip), %rdi      # 0x12fd0
leaq 0x58d3(%rip), %rsi      # 0xb04f
callq 0x5230
movq %rax, %rdi
callq 0x50f0
pushq $0x5
popq %rdi
callq 0x51a0
leaq 0x68(%rsp), %rdi
callq 0x5c6e
movq 0xd82e(%rip), %rdi      # 0x12fd0
leaq 0x58aa(%rip), %rsi      # 0xb053
callq 0x5230
movq %rax, %rdi
callq 0x50f0
movq 0xd813(%rip), %rdi      # 0x12fd0
callq 0x50f0
movq %rax, %rdi
callq 0x50f0
movq %rax, %rdi
callq 0x50f0
movq 0xd7f7(%rip), %rdi      # 0x12fd0
leaq 0x5878(%rip), %rsi      # 0xb058
callq 0x5230
movq %rax, %rdi
callq 0x50f0
leaq 0x18(%rsp), %rdi
callq 0x5c92
leaq 0x18(%rsp), %rdi
pushq $0xa
popq %rsi
callq 0x5d1e
leaq 0xc(%rsp), %rdx
movl $0x1, (%rdx)
leaq -0x1fa(%rip), %rsi      # 0x561c
leaq 0x18(%rsp), %rdi
callq 0x5d54
leaq 0x14(%rsp), %rdx
movl $0x2, (%rdx)
leaq -0x216(%rip), %rsi      # 0x561c
leaq 0x18(%rsp), %rdi
callq 0x5d54
leaq 0x10(%rsp), %rdx
movl $0x3, (%rdx)
leaq -0x232(%rip), %rsi      # 0x561c
leaq 0x18(%rsp), %rdi
callq 0x5d54
leaq -0x1df(%rip), %rsi      # 0x5680
leaq 0x18(%rsp), %rdi
callq 0x5dd2
movq 0xd760(%rip), %rbx      # 0x12fd0
leaq 0x57f4(%rip), %r14      # 0xb06b
leaq 0x18(%rsp), %r15
pushq $0x1
popq %rbp
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5230
movq %rax, %r12
movq %r15, %rdi
callq 0x5e4e
movq %r12, %rdi
movl %eax, %esi
callq 0x53c0
movq %rax, %rdi
callq 0x50f0
movq %r15, %rdi
callq 0x5e4e
testl %eax, %eax
je 0x58bc
movl %ebp, %edi
callq 0x51a0
jmp 0x587f
leaq 0x18(%rsp), %rdi
callq 0x5e6e
leaq 0x18(%rsp), %rdi
callq 0x5eb4
leaq 0x68(%rsp), %rdi
callq 0x5f12
xorl %eax, %eax
addq $0x248, %rsp            # imm = 0x248
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x590e
jmp 0x590e
jmp 0x590e
jmp 0x58fa
jmp 0x590e
jmp 0x58fa
movq %rax, %rbx
jmp 0x591b
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x5c58
jmp 0x591b
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x5eb4
leaq 0x68(%rsp), %rdi
callq 0x5f12
movq %rbx, %rdi
callq 0x53d0
nop