// File: /workspace/github_cpp_makefile_star2_O1/HQarroum[P]thread-pool/examples/working-with-functors/main.cpp
// Function: main
int main() {
  // Producer and consumer thread pools.
  thread::pool::pool_t pool_of_consumers(5);

  // Counting the start time.
  auto start = std::chrono::high_resolution_clock::now();

  // Creating the callable.
  auto callable = thread::pool::bind(pool_of_consumers, static_void_function);

  // Scheduling the producers.
  for (size_t i = 0; i < work_to_spawn; ++i) {
    auto result = callable(i);
    assert(result.get() == (int) (i + 1));
  }
  
  // Waiting for the consumers to complete.
  while (count < work_to_spawn)
    std::this_thread::sleep_for(std::chrono::milliseconds(100));

  // Measuring and dumping the elapsed time.
  auto end = std::chrono::high_resolution_clock::now();
  std::chrono::duration<double, std::milli> diff = end - start;
  std::cout << "Elasped time : " << diff.count() << " ms" << std::endl;

  return (0);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2f0, %rsp            # imm = 0x2F0
leaq 0x58(%rsp), %r14
movl $0x5, %esi
movq %r14, %rdi
callq 0x388a
callq 0x3050
movq %rax, %rbx
xorpd %xmm0, %xmm0
movq %rsp, %rsi
movapd %xmm0, (%rsi)
movapd %xmm0, 0x10(%rsi)
leaq -0x4d(%rip), %rax       # 0x361c
movq %rax, (%rsi)
leaq 0x15c7(%rip), %rax      # 0x4c3a
movq %rax, 0x18(%rsi)
leaq 0x15c4(%rip), %rax      # 0x4c42
movq %rax, 0x10(%rsi)
leaq 0x30(%rsp), %rdi
callq 0x4c64
movq %r14, 0x50(%rsp)
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x36a8
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
xorl %r13d, %r13d
movq %rsp, %r14
leaq 0x30(%rsp), %r15
leaq 0x28(%rsp), %r12
movq %r13, 0x28(%rsp)
movq 0x50(%rsp), %rsi
movq %r14, %rdi
movq %r15, %rdx
movq %r12, %rcx
callq 0x4cca
movq %r14, %rdi
callq 0x3952
incq %r13
cmpl %eax, %r13d
jne 0x37fb
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x36f3
callq 0x3a18
cmpq $0x3e8, %r13            # imm = 0x3E8
jne 0x36b8
movq 0x8b25(%rip), %rax      # 0xc228
cmpq $0x3e7, %rax            # imm = 0x3E7
ja 0x3748
movq %rsp, %r14
movq $0x0, (%rsp)
movq $0x5f5e100, 0x8(%rsp)   # imm = 0x5F5E100
movq %r14, %rdi
movq %r14, %rsi
callq 0x30b0
cmpl $-0x1, %eax
jne 0x3739
callq 0x3040
cmpl $0x4, (%rax)
je 0x371f
movq 0x8ae8(%rip), %rax      # 0xc228
cmpq $0x3e8, %rax            # imm = 0x3E8
jb 0x370e
callq 0x3050
movq %rax, %r14
movq 0x8861(%rip), %rdi      # 0xbfb8
leaq 0x38f4(%rip), %rsi      # 0x7052
movl $0xf, %edx
callq 0x32a0
subq %rbx, %r14
xorps %xmm0, %xmm0
cvtsi2sd %r14, %xmm0
divsd 0x388d(%rip), %xmm0     # 0x7008
movq 0x8836(%rip), %rdi      # 0xbfb8
callq 0x3320
movq %rax, %rbx
leaq 0x38d1(%rip), %rsi      # 0x7062
movl $0x3, %edx
movq %rax, %rdi
callq 0x32a0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3180
movq 0x40(%rsp), %rax
testq %rax, %rax
je 0x37de
leaq 0x30(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
leaq 0x58(%rsp), %rdi
callq 0x399e
xorl %eax, %eax
addq $0x2f0, %rsp            # imm = 0x2F0
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x381e(%rip), %rdi      # 0x7020
leaq 0x3835(%rip), %rsi      # 0x703e
leaq 0x3837(%rip), %rcx      # 0x7047
movl $0x2a, %edx
callq 0x3160
jmp 0x3882
jmp 0x3882
movq %rax, %rbx
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x3870
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x3870
jmp 0x3882
jmp 0x3854
jmp 0x3854
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x3857
callq 0x3a18
jmp 0x3857
movq %rax, %rbx
movq 0x40(%rsp), %rax
testq %rax, %rax
je 0x3870
leaq 0x30(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
leaq 0x58(%rsp), %rdi
callq 0x399e
movq %rbx, %rdi
callq 0x33a0
movq %rax, %rdi
callq 0x3a87