MCPcopy Create free account
hub / github.com/3rdparty/libprocess / Reader

Class Reader

include/process/http.hpp:302–339  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

300
301public:
302 class Reader
303 {
304 public:
305 // Returns data written to the pipe.
306 // Returns an empty read when end-of-file is reached.
307 // Returns Failure if the writer failed, or the read-end
308 // is closed.
309 Future<std::string> read();
310
311 // Performs a series of asynchronous reads, until EOF is reached.
312 // Returns the concatenated result of the reads.
313 // Returns Failure if the writer failed, or the read-end
314 // is closed.
315 Future<std::string> readAll();
316
317 // Closing the read-end of the pipe before the write-end closes
318 // or fails will notify the writer that the reader is no longer
319 // interested. Returns false if the read-end was already closed.
320 bool close();
321
322 // Comparison operators useful for checking connection equality.
323 bool operator==(const Reader& other) const { return data == other.data; }
324 bool operator!=(const Reader& other) const { return !(*this == other); }
325
326 private:
327 friend class Pipe;
328
329 enum State
330 {
331 OPEN,
332 CLOSED,
333 };
334
335 explicit Reader(const std::shared_ptr<Data>& _data)
336 : data(_data) {}
337
338 std::shared_ptr<Data> data;
339 };
340
341 class Writer
342 {

Callers 1

readerMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected