Example #1
0
static void
do_xmit_work(struct c8250_serial *device)
{
    struct stream_interface *si = &device->tx;
    struct stream_pkt *packet = stream_get_head(si);

    if (packet == NULL) {
        return;
    }

    assert(packet->data);
    while (!tx_ready()) {
        thr_write(packet->data[packet->xferred++]);
        assert(packet->xferred <= packet->length);
        if (packet->xferred == packet->length) {
            packet = stream_switch_head(si);
            if (packet == NULL) {
                break;
           }
        }
    }

    ier_set_txie(1);
    return;
}
Example #2
0
bool
LogSinkImpl::write(const char* s, size_t n) 
{ 
#   ifdef LINKO_LOG_THREAD
    if (_thread) return thr_write(s, n);
#   endif    

#   if defined LINKO_LOG_WRITE_WO_MUTEX && defined LINKO_LOG_MT
    // Without mutex, it's much safer to always return true (success)!
    return mx_write(s, n), true;
#   else
    // It seems that mutex lock is unnecessary here!
    // Important is O_APPEND flag on open.
    // Performance cost of this lock is very big for high congestions.
    // Mutex is only important for correct rotate() operation.
    MUTEX_GUARD(_mutex);
    return mx_write(s, n);
#   endif
}