// File: shaovie[P]reactor/src/async_send.cpp
// Function: async_send::on_read()
bool async_send::on_read() {
    if (this->readq->empty()) {
        this->mtx.lock();
        std::swap(this->readq, this->writeq);
        this->mtx.unlock();
    }
    for (auto i = 0; i < 256 && !this->readq->empty(); ++i) { // 1次最多处理256个
        async_send::item &asi = this->readq->front();
        poll_desc *pd = this->poll->get_poll_desc(asi.fd);
        if (pd != nullptr && asi.seq == pd->seq) // 保证对象没有释放呢
            pd->eh->sync_ordered_send(asi.asb);
        else
            delete[] asi.asb.buf;
        
        this->readq->pop_front();
    }
    if (!this->readq->empty()) // Ignore readable eventfd, continue
        return true;

    int64_t v = 0;
    int ret = 0;
    do {
        ret = ::read(this->efd, (void *)&v, sizeof(v));
    } while (ret == -1 && errno == EINTR);

    this->notified.store(0);
    return true;
}

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x50(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x68(%rax), %rdi
callq 0x14a90
testb $0x1, %al
jne 0x209b2
jmp 0x209e3
movq 0x20(%rsp), %rdi
addq $0x38, %rdi
callq 0x15f40
movq 0x20(%rsp), %rsi
movq %rsi, %rdi
addq $0x68, %rdi
addq $0x70, %rsi
callq 0x15990
movq 0x20(%rsp), %rdi
addq $0x38, %rdi
callq 0x157a0
movl $0x0, 0x4c(%rsp)
xorl %eax, %eax
cmpl $0x100, 0x4c(%rsp)      # imm = 0x100
movb %al, 0x1f(%rsp)
jge 0x20a0f
movq 0x20(%rsp), %rax
movq 0x68(%rax), %rdi
callq 0x14a90
xorb $-0x1, %al
movb %al, 0x1f(%rsp)
movb 0x1f(%rsp), %al
testb $0x1, %al
jne 0x20a1c
jmp 0x20ac0
movq 0x20(%rsp), %rax
movq 0x68(%rax), %rdi
callq 0x16080
movq %rax, %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x40(%rsp)
movq 0x18(%rax), %rdi
movq 0x40(%rsp), %rax
movl (%rax), %esi
callq 0x14c80
movq %rax, 0x38(%rsp)
cmpq $0x0, 0x38(%rsp)
je 0x20a82
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x38(%rsp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x20a82
movq 0x38(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x40(%rsp), %rsi
addq $0x18, %rsi
movq (%rdi), %rax
callq *0x50(%rax)
jmp 0x20aa2
movq 0x40(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0x10(%rsp)
cmpq $0x0, %rax
je 0x20aa0
movq 0x10(%rsp), %rdi
callq 0x155c0
jmp 0x20aa2
movq 0x20(%rsp), %rax
movq 0x68(%rax), %rdi
callq 0x14400
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
jmp 0x209eb
movq 0x20(%rsp), %rax
movq 0x68(%rax), %rdi
callq 0x14a90
testb $0x1, %al
jne 0x20adc
movb $0x1, 0x5f(%rsp)
jmp 0x20bae
movq $0x0, 0x30(%rsp)
movl $0x0, 0x2c(%rsp)
movq 0x20(%rsp), %rax
movl 0x30(%rax), %edi
leaq 0x30(%rsp), %rsi
movl $0x8, %edx
callq 0x15880
movl %eax, 0x2c(%rsp)
xorl %eax, %eax
cmpl $-0x1, 0x2c(%rsp)
movb %al, 0xf(%rsp)
jne 0x20b24
callq 0x140c0
cmpl $0x4, (%rax)
sete %al
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0x20aed
movq 0x20(%rsp), %rax
addq $0x60, %rax
movq %rax, 0x70(%rsp)
movl $0x0, 0x6c(%rsp)
movl $0x5, 0x68(%rsp)
movq 0x70(%rsp), %rax
movq %rax, (%rsp)
movl 0x68(%rsp), %edi
movl $0xffff, %esi           # imm = 0xFFFF
callq 0x140d0
movl %eax, 0x64(%rsp)
movl 0x68(%rsp), %eax
movl %eax, 0x8(%rsp)
movl 0x6c(%rsp), %ecx
movl %ecx, 0x60(%rsp)
subl $0x3, %eax
je 0x20b93
jmp 0x20b7c
movl 0x8(%rsp), %eax
subl $0x5, %eax
je 0x20b9f
jmp 0x20b87
movq (%rsp), %rax
movl 0x60(%rsp), %ecx
movl %ecx, (%rax)
jmp 0x20ba9
movq (%rsp), %rax
movl 0x60(%rsp), %ecx
movl %ecx, (%rax)
jmp 0x20ba9
movq (%rsp), %rcx
movl 0x60(%rsp), %eax
xchgl %eax, (%rcx)
movb $0x1, 0x5f(%rsp)
movb 0x5f(%rsp), %al
andb $0x1, %al
addq $0x78, %rsp
retq
nopl (%rax)