// File: enbock[P]Warp10Server/ulib/src/EventDispatcher.cpp
// Function: u::EventDispatcher::dispatchEvent(u::Event*)
Event* EventDispatcher::dispatchEvent(Event *event)
{
	lock();

	Vector<Callback>* pVec = getEventVector(event->_type);
	if(pVec != null)
	{
		Vector<Callback> vec = *pVec;
		unlock();

		int64 i=0, l = vec.size();
		for(i=0; i<l; i++)
		{
			Callback cb = vec.at(i);
			trace(
				"DispatchEvent: " + *(event->_type)
				+ "\033[36m -> "+cb.toString()
			);
			Event* ev = event->clone();
			ev->_target = this;
			cb.arg = ev;

			if(ThreadSystem::create(&cb) == false)
			{
				// thread system is terminating
				ev->destroy();
			}
		}

		return event;
	}
	else
	{
		trace(
			"\033[32mNo listener for " + *event->type()
			+ " on target "+ toString() + "."
		);
	}
	unlock();
	return event;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x310, %rsp            # imm = 0x310
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x2a8(%rbp)
callq 0x40d7d0
movq -0x2a8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rsi
callq 0x408c90
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x409432
movq -0x20(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x409d80
movq -0x2a8(%rbp), %rdi
callq 0x40d740
jmp 0x409061
movq $0x0, -0x88(%rbp)
leaq -0x70(%rbp), %rdi
addq $0x38, %rdi
callq 0x409ce0
movq %rax, -0x90(%rbp)
movq $0x0, -0x88(%rbp)
movq -0x88(%rbp), %rax
cmpq -0x90(%rbp), %rax
jge 0x40940e
leaq -0x38(%rbp), %rdi
movq -0x88(%rbp), %rsi
callq 0x409b40
movq %rax, -0x2b0(%rbp)
jmp 0x4090b8
movq -0x2b0(%rbp), %rsi
leaq -0xe8(%rbp), %rdi
callq 0x407210
jmp 0x4090cd
movq $0x61a6a0, %rdi         # imm = 0x61A6A0
leaq 0x195f9e(%rip), %rsi    # 0x59f079
callq 0x47dcd0
movq %rax, -0x2b8(%rbp)
jmp 0x4090e9
movb $0x0, -0x149(%rbp)
movb $0x0, -0x14a(%rbp)
movb $0x0, -0x1a9(%rbp)
movb $0x0, -0x1ab(%rbp)
movb $0x1, %al
testb $0x1, %al
jne 0x409110
jmp 0x409195
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rdx
addq $0x38, %rdx
leaq 0x196229(%rip), %rsi    # 0x59f34c
leaq -0x148(%rbp), %rdi
callq 0x407c00
jmp 0x409131
movb $0x1, -0x149(%rbp)
leaq 0x19621d(%rip), %rdx    # 0x59f35c
leaq -0x128(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0x405740
jmp 0x409154
movb $0x1, -0x14a(%rbp)
leaq -0x1a8(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x4073d0
jmp 0x409170
movb $0x1, -0x1a9(%rbp)
leaq -0x170(%rbp), %rdx
leaq -0x108(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x407710
jmp 0x409193
jmp 0x4091cd
leaq -0x1aa(%rbp), %rdi
movq %rdi, -0x2c0(%rbp)
callq 0x415b00
movq -0x2c0(%rbp), %rdx
movb $0x1, -0x1ab(%rbp)
leaq 0x1b58cd(%rip), %rsi    # 0x5bea8a
leaq -0x108(%rbp), %rdi
callq 0x405e40
jmp 0x4091cb
jmp 0x4091cd
movq -0x2b8(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x490550
movq %rax, -0x2c8(%rbp)
jmp 0x4091e9
movq -0x2c8(%rbp), %rdi
leaq 0x195ea4(%rip), %rsi    # 0x59f09b
callq 0x47dcd0
movq %rax, -0x2d0(%rbp)
jmp 0x409205
movq -0x2d0(%rbp), %rdi
movq $0x47d5b0, %rsi         # imm = 0x47D5B0
callq 0x47c7c0
jmp 0x40921a
leaq -0x108(%rbp), %rdi
callq 0x48dbd0
testb $0x1, -0x1ab(%rbp)
jne 0x409231
jmp 0x40923d
leaq -0x1aa(%rbp), %rdi
callq 0x415b20
testb $0x1, -0x1a9(%rbp)
jne 0x409248
jmp 0x409254
leaq -0x1a8(%rbp), %rdi
callq 0x404d10
testb $0x1, -0x14a(%rbp)
jne 0x40925f
jmp 0x40926b
leaq -0x128(%rbp), %rdi
callq 0x48dbd0
testb $0x1, -0x149(%rbp)
jne 0x409276
jmp 0x409282
leaq -0x148(%rbp), %rdi
callq 0x48dbd0
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
callq *%rax
movq %rax, -0x2d8(%rbp)
jmp 0x409298
movq -0x2a8(%rbp), %rcx
movq -0x2d8(%rbp), %rax
movq %rax, -0x1b8(%rbp)
movq -0x1b8(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x1b8(%rbp), %rax
movq %rax, -0x98(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x410e70
movb %al, -0x2d9(%rbp)
jmp 0x4092da
movb -0x2d9(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x4093dd
movq -0x1b8(%rbp), %rdi
movq (%rdi), %rax
movq (%rax), %rax
callq *%rax
jmp 0x4092ff
jmp 0x4093dd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x409424
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x409400
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x4093c4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x4093ab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x409392
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x409379
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x48dbd0
testb $0x1, -0x1ab(%rbp)
jne 0x409384
jmp 0x409390
leaq -0x1aa(%rbp), %rdi
callq 0x415b20
jmp 0x409392
testb $0x1, -0x1a9(%rbp)
jne 0x40939d
jmp 0x4093a9
leaq -0x1a8(%rbp), %rdi
callq 0x404d10
jmp 0x4093ab
testb $0x1, -0x14a(%rbp)
jne 0x4093b6
jmp 0x4093c2
leaq -0x128(%rbp), %rdi
callq 0x48dbd0
jmp 0x4093c4
testb $0x1, -0x149(%rbp)
jne 0x4093cf
jmp 0x4093db
leaq -0x148(%rbp), %rdi
callq 0x48dbd0
jmp 0x409400
leaq -0xe8(%rbp), %rdi
callq 0x406450
movq -0x88(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x88(%rbp)
jmp 0x40908b
leaq -0xe8(%rbp), %rdi
callq 0x406450
jmp 0x409424
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x4099a0
jmp 0x40972d
leaq -0x70(%rbp), %rdi
callq 0x4099a0
jmp 0x40973a
movq $0x61a6a0, %rdi         # imm = 0x61A6A0
leaq 0x195c39(%rip), %rsi    # 0x59f079
callq 0x47dcd0
movq %rax, -0x2e8(%rbp)
movb $0x0, -0x239(%rbp)
movb $0x0, -0x23a(%rbp)
movb $0x0, -0x299(%rbp)
movb $0x0, -0x29a(%rbp)
movb $0x0, -0x29c(%rbp)
movb $0x1, %al
testb $0x1, %al
jne 0x40947a
jmp 0x40952f
movq -0x18(%rbp), %rdi
callq 0x407890
movq %rax, %rdx
addq $0x38, %rdx
leaq 0x195f23(%rip), %rsi    # 0x59f3b4
leaq -0x238(%rbp), %rdi
movq %rdi, -0x2f0(%rbp)
callq 0x407c00
movq -0x2f0(%rbp), %rsi
movb $0x1, -0x239(%rbp)
leaq 0x195f11(%rip), %rdx    # 0x59f3ca
leaq -0x218(%rbp), %rdi
callq 0x405740
jmp 0x4094c7
movq -0x2a8(%rbp), %rsi
movb $0x1, -0x23a(%rbp)
movq (%rsi), %rax
movq 0x18(%rax), %rax
leaq -0x298(%rbp), %rdi
callq *%rax
jmp 0x4094e7
movb $0x1, -0x299(%rbp)
leaq -0x260(%rbp), %rdx
leaq -0x1f8(%rbp), %rdi
leaq -0x218(%rbp), %rsi
callq 0x407710
jmp 0x40950a
movb $0x1, -0x29a(%rbp)
leaq 0x19a2b5(%rip), %rdx    # 0x5a37cd
leaq -0x1d8(%rbp), %rdi
leaq -0x1f8(%rbp), %rsi
callq 0x405740
jmp 0x40952d
jmp 0x409567
leaq -0x29b(%rbp), %rdi
movq %rdi, -0x2f8(%rbp)
callq 0x415b00
movq -0x2f8(%rbp), %rdx
movb $0x1, -0x29c(%rbp)
leaq 0x1b5533(%rip), %rsi    # 0x5bea8a
leaq -0x1d8(%rbp), %rdi
callq 0x405e40
jmp 0x409565
jmp 0x409567
movq -0x2e8(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
callq 0x490550
movq %rax, -0x300(%rbp)
jmp 0x409583
movq -0x300(%rbp), %rdi
leaq 0x195b0a(%rip), %rsi    # 0x59f09b
callq 0x47dcd0
movq %rax, -0x308(%rbp)
jmp 0x40959f
movq -0x308(%rbp), %rdi
movq $0x47d5b0, %rsi         # imm = 0x47D5B0
callq 0x47c7c0
jmp 0x4095b4
leaq -0x1d8(%rbp), %rdi
callq 0x48dbd0
testb $0x1, -0x29c(%rbp)
jne 0x4095cb
jmp 0x4095d7
leaq -0x29b(%rbp), %rdi
callq 0x415b20
testb $0x1, -0x29a(%rbp)
jne 0x4095e2
jmp 0x4095ee
leaq -0x1f8(%rbp), %rdi
callq 0x48dbd0
testb $0x1, -0x299(%rbp)
jne 0x4095f9
jmp 0x409605
leaq -0x298(%rbp), %rdi
callq 0x404d10
testb $0x1, -0x23a(%rbp)
jne 0x409610
jmp 0x40961c
leaq -0x218(%rbp), %rdi
callq 0x48dbd0
testb $0x1, -0x239(%rbp)
jne 0x409627
jmp 0x409633
leaq -0x238(%rbp), %rdi
callq 0x48dbd0
jmp 0x409719
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x409700
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x4096e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x4096ce
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x4096b5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x40969c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0x48dbd0
testb $0x1, -0x29c(%rbp)
jne 0x4096a7
jmp 0x4096b3
leaq -0x29b(%rbp), %rdi
callq 0x415b20
jmp 0x4096b5
testb $0x1, -0x29a(%rbp)
jne 0x4096c0
jmp 0x4096cc
leaq -0x1f8(%rbp), %rdi
callq 0x48dbd0
jmp 0x4096ce
testb $0x1, -0x299(%rbp)
jne 0x4096d9
jmp 0x4096e5
leaq -0x298(%rbp), %rdi
callq 0x404d10
jmp 0x4096e7
testb $0x1, -0x23a(%rbp)
jne 0x4096f2
jmp 0x4096fe
leaq -0x218(%rbp), %rdi
callq 0x48dbd0
jmp 0x409700
testb $0x1, -0x239(%rbp)
jne 0x40970b
jmp 0x409717
leaq -0x238(%rbp), %rdi
callq 0x48dbd0
jmp 0x40973a
movq -0x2a8(%rbp), %rdi
callq 0x40d740
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x310, %rsp            # imm = 0x310
popq %rbp
retq
movq -0x78(%rbp), %rdi
callq 0x4be910
nopw %cs:(%rax,%rax)