Esempio n. 1
0
    bool transferLeft(cyclic_buffer<capacity>& buf, In& in, Out& out) {
        if (!buf.isEmpty()) {
            transfer(buf, out);
        } else {
            try {
                // read() throws exception if nothing can be read
                transfer(in, buf);

                // Or doesn't throw returning 0?
                return buf.isEmpty();
            } catch (const errno_exception& ex) {
                return true;
            }
        }
    }
Esempio n. 2
0
 void transfer(cyclic_buffer<capacity>& buf, Out& out) {
     if (!buf.isEmpty()) {
         char buffer[TRANSFER_CHUNK_SIZE];
         size_t s = buf.seek(buffer, sizeof(buffer));
         size_t numWritten = out.write(buffer, s);
         buf.skip(numWritten);
     }
 }