// File: metopa[P]HTTP_Server/src/threads/CWorkerThread.cpp
// Function: CWorkerThread::run()
void CWorkerThread::run() {
	int processedCount = 0;
	Log.ger<>( THREADS, "Worker thread", id_m, "successfully started" );
	while ( 1 ) {
		try {
			unique_ptr<CRequest> current( queue_m->pop() );
			if ( !current )
				break;

			Log.ger<>( THREADS, "Worker thread", id_m, "has new job" );
			current->receive();
			current->parse();
			current->generate();
			current->sendBack();

			processedCount++;
		}
		catch ( EmptyDataException& e ) {
			Log.ger( DEBUG_NETWORK, e );
		}
		catch ( NetworkException& e ) {
			Log.ger( NETWORK, e );
		}
		catch ( bad_alloc& e ) { }
	}

	Log.ger<>( INFO, "Thread_id:requests_processed\t", id_m, CLogger::NoSpace(), ":", CLogger::NoSpace(),
			   processedCount );
	Log.ger<>( THREADS, "Worker thread", id_m, "shuts down" );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rcx
movq %rcx, -0x50(%rbp)
movl $0x0, -0xc(%rbp)
addq $0x8, %rcx
leaq 0x14dda(%rip), %rdi     # 0x3f6e0
movl $0x9, %esi
leaq 0x2583(%rip), %rdx      # 0x2ce95
leaq 0x252d(%rip), %r8       # 0x2ce46
callq 0x2ab60
movq -0x50(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x2ac30
movq %rax, -0x58(%rbp)
jmp 0x2a931
movq -0x58(%rbp), %rsi
leaq -0x18(%rbp), %rdi
callq 0x2ad10
leaq -0x18(%rbp), %rdi
callq 0x2ad40
testb $0x1, %al
jne 0x2a968
movl $0x3, -0x28(%rbp)
jmp 0x2a9ed
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x2aa1b
movq -0x50(%rbp), %rcx
addq $0x8, %rcx
leaq 0x14d69(%rip), %rdi     # 0x3f6e0
leaq 0x2517(%rip), %rdx      # 0x2ce95
leaq 0x251e(%rip), %r8       # 0x2cea3
movl $0x9, %esi
callq 0x2ad70
jmp 0x2a991
leaq -0x18(%rbp), %rdi
callq 0x2ae40
movq %rax, %rdi
callq 0x26bc0
jmp 0x2a9a4
leaq -0x18(%rbp), %rdi
callq 0x2ae40
movq %rax, %rdi
callq 0x262a0
jmp 0x2a9b7
leaq -0x18(%rbp), %rdi
callq 0x2ae40
movq %rax, %rdi
callq 0x26af0
jmp 0x2a9ca
leaq -0x18(%rbp), %rdi
callq 0x2ae40
movq %rax, %rdi
callq 0x26b40
jmp 0x2a9dd
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
movl $0x0, -0x28(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x2ae60
movl -0x28(%rbp), %eax
testl %eax, %eax
je 0x2aa04
jmp 0x2a9ff
jmp 0x2aadd
jmp 0x2aa53
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x2ae60
movl -0x24(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl $0x3, %ecx
cmpl %ecx, %eax
jne 0x2aa58
movq -0x20(%rbp), %rdi
callq 0x6230
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdx
leaq 0x14c9e(%rip), %rdi     # 0x3f6e0
movl $0x5, %esi
callq 0x2af80
jmp 0x2aa4e
callq 0x6880
jmp 0x2a91e
movl -0x5c(%rbp), %eax
movl $0x2, %ecx
cmpl %ecx, %eax
jne 0x2aa8f
movq -0x20(%rbp), %rdi
callq 0x6230
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdx
leaq 0x14c64(%rip), %rdi     # 0x3f6e0
movl $0x4, %esi
callq 0x2aec0
jmp 0x2aa88
callq 0x6880
jmp 0x2aa53
movl -0x5c(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x2ab46
movq -0x20(%rbp), %rdi
callq 0x6230
movq %rax, -0x30(%rbp)
callq 0x6880
jmp 0x2aa53
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
callq 0x6880
jmp 0x2aac6
jmp 0x2ab46
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
callq 0x6880
jmp 0x2aadb
jmp 0x2ab46
movq -0x50(%rbp), %rcx
addq $0x8, %rcx
leaq 0x14bf4(%rip), %rdi     # 0x3f6e0
movl $0x2, %esi
leaq 0x23b7(%rip), %rdx      # 0x2ceaf
leaq -0x41(%rbp), %r8
leaq 0x1c0f(%rip), %r9       # 0x2c712
leaq -0x42(%rbp), %r10
leaq -0xc(%rbp), %rax
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x2b040
movq -0x50(%rbp), %rcx
addq $0x8, %rcx
leaq 0x14bb8(%rip), %rdi     # 0x3f6e0
movl $0x9, %esi
leaq 0x2361(%rip), %rdx      # 0x2ce95
leaq 0x22d9(%rip), %r8       # 0x2ce14
callq 0x2b130
addq $0x70, %rsp
popq %rbp
retq
movq -0x20(%rbp), %rdi
callq 0x6920
movq %rax, %rdi
callq 0xb060
nopw (%rax,%rax)