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

Method write

src/http.cpp:548–576  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

546
547
548bool Pipe::Writer::write(string s)
549{
550 bool written = false;
551 Owned<Promise<string>> read;
552
553 synchronized (data->lock) {
554 // Ignore writes if either end of the pipe is closed or failed!
555 if (data->writeEnd == Writer::OPEN && data->readEnd == Reader::OPEN) {
556 // Don't bother surfacing empty writes to the readers.
557 if (!s.empty()) {
558 if (data->reads.empty()) {
559 data->writes.push(std::move(s));
560 } else {
561 read = data->reads.front();
562 data->reads.pop();
563 }
564 }
565 written = true;
566 }
567 }
568
569 // NOTE: We set the promise outside the critical section to avoid
570 // triggering callbacks that try to reacquire the lock.
571 if (read.get() != nullptr) {
572 read->set(std::move(s)); // NOLINT(misc-use-after-move)
573 }
574
575 return written;
576}
577
578
579bool Pipe::Writer::close()

Callers 7

encodeFunction · 0.80
on_bodyMethod · 0.80
on_bodyMethod · 0.80
encodeMethod · 0.80
encodeMethod · 0.80
TEST_PFunction · 0.80
TESTFunction · 0.80

Calls 5

pushMethod · 0.80
synchronizedFunction · 0.70
emptyMethod · 0.45
getMethod · 0.45
setMethod · 0.45

Tested by 2

TEST_PFunction · 0.64
TESTFunction · 0.64