コード例 #1
0
void middleman_event_handler::alteration(continuable* ptr,
                                         event_bitmask e,
                                         fd_meta_event etype) {
    native_socket_type fd;
    switch (e) {
        case event::read:
            fd = ptr->read_handle();
            break;
        case event::write: {
            fd = ptr->write_handle();
            break;
        }
        case event::both: {
            fd = ptr->read_handle();
            auto wrfd = ptr->write_handle();
            if (fd != wrfd) {
                CPPA_LOG_DEBUG("read_handle != write_handle, split "
                               "into two function calls");
                // split into two function calls
                e = event::read;
                alteration(ptr, event::write, etype);
            }
            break;
        }
        default:
            CPPA_CRITICAL("invalid bitmask");
            return;
    }
    m_alterations.emplace_back(fd_meta_info(fd, ptr, e), etype);
}
コード例 #2
0
 void alteration(const continuable_reader_ptr& ptr,
                 event_bitmask e,
                 fd_meta_event etype) {
     native_socket_type fd;
     switch (e) {
         case event::read:
             fd = ptr->read_handle();
             break;
         case event::write: {
             auto wptr = ptr->as_io();
             if (wptr) fd = wptr->write_handle();
             else {
                 CPPA_LOG_ERROR("ptr->downcast() returned nullptr");
                 return;
             }
             break;
         }
         case event::both: {
             fd = ptr->read_handle();
             auto wptr = ptr->as_io();
             if (wptr) {
                 auto wrfd = wptr->write_handle();
                 if (fd != wrfd) {
                     CPPA_LOG_DEBUG("read_handle != write_handle, split "
                                    "into two function calls");
                     // split into two function calls
                     e = event::read;
                     alteration(ptr, event::write, etype);
                 }
             }
             else {
                 CPPA_LOG_ERROR("ptr->downcast() returned nullptr");
                 return;
             }
             break;
         }
         default:
             CPPA_LOG_ERROR("invalid bitmask");
             return;
     }
     m_alterations.emplace_back(fd_meta_info(fd, ptr, e), etype);
 }