int PS2Keyboard::available() { processBytes(); int count = (head_ - tail_ + kBufferArraySize) % kBufferArraySize; if (debug_) debug_->recordKeyboardAvailable(count); return count; }
void TlsPskAdaptor::processBytes(std::vector<Botan::byte> buffer) { if (buffer.size() == 0) return handleEof(); auto bytesNeeded = channel->received_data(kj::mv(buffer)); if (bytesNeeded) { buffer.resize(bytesNeeded); tasks.add(stream->read(buffer.data(), buffer.size(), buffer.size()).then( [this, buffer = kj::mv(buffer)](size_t bytesRead) mutable { buffer.resize(bytesRead); processBytes(kj::mv(buffer)); })); } else startReadLoop(); }
void measureMemory(bool measureProcessMemory) { peakBytes = measureProcessMemory ? processBytes() : 0; }