MCPcopy Create free account
hub / github.com/Kitware/CMake / read

Method read

Utilities/cmcppdap/src/io.cpp:42–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40 }
41
42 size_t read(void* buffer, size_t bytes) override {
43 std::unique_lock<std::mutex> lock(mutex);
44 auto out = reinterpret_cast<uint8_t*>(buffer);
45 size_t n = 0;
46 while (true) {
47 cv.wait(lock, [&] { return closed || data.size() > 0; });
48 if (closed) {
49 return n;
50 }
51 for (; n < bytes && data.size() > 0; n++) {
52 out[n] = data.front();
53 data.pop_front();
54 }
55 if (n == bytes) {
56 return n;
57 }
58 }
59 }
60
61 bool write(const void* buffer, size_t bytes) override {
62 std::unique_lock<std::mutex> lock(mutex);

Callers

nothing calls this directly

Calls 4

waitMethod · 0.80
pop_frontMethod · 0.80
sizeMethod · 0.45
frontMethod · 0.45

Tested by

no test coverage detected