// File: 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
movq %rsp, %rbp
subq $0x3a0, %rsp            # imm = 0x3A0
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq 0x1e690(%rip), %rdi     # 0x24fd0
movq %rdi, -0x328(%rbp)
leaq 0x10702(%rip), %rsi     # 0x17050
callq 0x62d0
movq %rax, %rdi
movq 0x1e63b(%rip), %rsi     # 0x24f98
callq 0x6320
leaq -0x1f0(%rbp), %rdi
movl $0xa, %esi
movl $0x14, %edx
callq 0x7530
movq -0x328(%rbp), %rdi
leaq 0x106d8(%rip), %rsi     # 0x1705e
callq 0x62d0
movq %rax, -0x320(%rbp)
jmp 0x6994
movq -0x320(%rbp), %rdi
movq 0x1e5f6(%rip), %rsi     # 0x24f98
callq 0x6320
jmp 0x69a9
movl $0x0, -0x200(%rbp)
cmpl $0x64, -0x200(%rbp)
jge 0x6a72
movl -0x200(%rbp), %r8d
leaq 0xcd2(%rip), %rax       # 0x76a0
movq %rax, -0x268(%rbp)
movq $0x0, -0x260(%rbp)
movq -0x268(%rbp), %rsi
movq -0x260(%rbp), %rdx
leaq -0x258(%rbp), %rdi
leaq -0x201(%rbp), %rcx
callq 0x7700
jmp 0x6a03
leaq -0x1f0(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x7800
jmp 0x6a18
leaq -0x258(%rbp), %rdi
callq 0x78a0
movl -0x200(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x200(%rbp)
jmp 0x69b3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1f8(%rbp)
movl %eax, -0x1fc(%rbp)
jmp 0x6dea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1f8(%rbp)
movl %eax, -0x1fc(%rbp)
leaq -0x258(%rbp), %rdi
callq 0x78a0
jmp 0x6dea
movq 0x1e557(%rip), %rdi     # 0x24fd0
leaq 0x105e4(%rip), %rsi     # 0x17064
callq 0x62d0
movq %rax, -0x330(%rbp)
jmp 0x6a8e
movq -0x330(%rbp), %rdi
movq 0x1e4fc(%rip), %rsi     # 0x24f98
callq 0x6320
jmp 0x6aa3
movl $0x5, %edi
callq 0x6220
jmp 0x6aaf
leaq -0x1f0(%rbp), %rdi
callq 0x78d0
jmp 0x6abd
movq 0x1e50c(%rip), %rdi     # 0x24fd0
leaq 0x1059d(%rip), %rsi     # 0x17068
callq 0x62d0
movq %rax, -0x338(%rbp)
jmp 0x6ad9
movq -0x338(%rbp), %rdi
movq 0x1e4b1(%rip), %rsi     # 0x24f98
callq 0x6320
jmp 0x6aee
movq 0x1e4db(%rip), %rdi     # 0x24fd0
movq 0x1e49c(%rip), %rsi     # 0x24f98
callq 0x6320
movq %rax, -0x340(%rbp)
jmp 0x6b0a
movq -0x340(%rbp), %rdi
movq 0x1e480(%rip), %rsi     # 0x24f98
callq 0x6320
movq %rax, -0x348(%rbp)
jmp 0x6b26
movq -0x348(%rbp), %rdi
movq 0x1e464(%rip), %rsi     # 0x24f98
callq 0x6320
jmp 0x6b3b
movq 0x1e48e(%rip), %rdi     # 0x24fd0
leaq 0x10524(%rip), %rsi     # 0x1706d
callq 0x62d0
movq %rax, -0x350(%rbp)
jmp 0x6b57
movq -0x350(%rbp), %rdi
movq 0x1e433(%rip), %rsi     # 0x24f98
callq 0x6320
jmp 0x6b6c
leaq -0x2b8(%rbp), %rdi
callq 0x7910
jmp 0x6b7a
leaq -0x2b8(%rbp), %rdi
movl $0xa, %esi
callq 0x79f0
jmp 0x6b8d
movl $0x1, -0x2bc(%rbp)
leaq -0x2bc(%rbp), %rax
movq %rax, -0x2c8(%rbp)
movq -0x2c8(%rbp), %rsi
leaq -0x393(%rip), %rdi      # 0x6820
callq 0x7b40
movq %rdx, -0x360(%rbp)
movq %rax, -0x358(%rbp)
jmp 0x6bc8
movq -0x360(%rbp), %rax
movq -0x358(%rbp), %rcx
movq %rcx, -0x2d8(%rbp)
movq %rax, -0x2d0(%rbp)
movq -0x2d8(%rbp), %rsi
movq -0x2d0(%rbp), %rdx
leaq -0x2b8(%rbp), %rdi
callq 0x7a70
jmp 0x6c00
movl $0x2, -0x2dc(%rbp)
leaq -0x2dc(%rbp), %rax
movq %rax, -0x2e8(%rbp)
movq -0x2e8(%rbp), %rsi
leaq -0x406(%rip), %rdi      # 0x6820
callq 0x7b40
movq %rdx, -0x370(%rbp)
movq %rax, -0x368(%rbp)
jmp 0x6c3b
movq -0x370(%rbp), %rax
movq -0x368(%rbp), %rcx
movq %rcx, -0x2f8(%rbp)
movq %rax, -0x2f0(%rbp)
movq -0x2f8(%rbp), %rsi
movq -0x2f0(%rbp), %rdx
leaq -0x2b8(%rbp), %rdi
callq 0x7a70
jmp 0x6c73
movl $0x3, -0x2fc(%rbp)
leaq -0x2fc(%rbp), %rax
movq %rax, -0x308(%rbp)
movq -0x308(%rbp), %rsi
leaq -0x479(%rip), %rdi      # 0x6820
callq 0x7b40
movq %rdx, -0x380(%rbp)
movq %rax, -0x378(%rbp)
jmp 0x6cae
movq -0x380(%rbp), %rax
movq -0x378(%rbp), %rcx
movq %rcx, -0x318(%rbp)
movq %rax, -0x310(%rbp)
movq -0x318(%rbp), %rsi
movq -0x310(%rbp), %rdx
leaq -0x2b8(%rbp), %rdi
callq 0x7a70
jmp 0x6ce6
leaq -0x44d(%rip), %rsi      # 0x68a0
leaq -0x2b8(%rbp), %rdi
callq 0x7ba0
jmp 0x6cfb
jmp 0x6cfd
jmp 0x6cff
movq 0x1e2ca(%rip), %rdi     # 0x24fd0
leaq 0x10373(%rip), %rsi     # 0x17080
callq 0x62d0
movq %rax, -0x388(%rbp)
jmp 0x6d1b
leaq -0x2b8(%rbp), %rdi
callq 0x7c70
movl %eax, -0x38c(%rbp)
jmp 0x6d2f
movl -0x38c(%rbp), %esi
movq -0x388(%rbp), %rdi
callq 0x6520
movq %rax, -0x398(%rbp)
jmp 0x6d4a
movq -0x398(%rbp), %rdi
movq 0x1e240(%rip), %rsi     # 0x24f98
callq 0x6320
jmp 0x6d5f
leaq -0x2b8(%rbp), %rdi
callq 0x7c70
movl %eax, -0x39c(%rbp)
jmp 0x6d73
movl -0x39c(%rbp), %eax
cmpl $0x0, %eax
jne 0x6da0
jmp 0x6db1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1f8(%rbp)
movl %eax, -0x1fc(%rbp)
leaq -0x2b8(%rbp), %rdi
callq 0x7d70
jmp 0x6dea
movl $0x1, %edi
callq 0x6220
jmp 0x6dac
jmp 0x6cfd
leaq -0x2b8(%rbp), %rdi
callq 0x7cb0
jmp 0x6dbf
movl $0x0, -0x4(%rbp)
leaq -0x2b8(%rbp), %rdi
callq 0x7d70
leaq -0x1f0(%rbp), %rdi
callq 0x7e00
movl -0x4(%rbp), %eax
addq $0x3a0, %rsp            # imm = 0x3A0
popq %rbp
retq
leaq -0x1f0(%rbp), %rdi
callq 0x7e00
movq -0x1f8(%rbp), %rdi
callq 0x6530
nopw %cs:(%rax,%rax)