Remove the concept of the 'stdio channel' from class DrivenEngine

This commit is contained in:
2025-12-18 15:28:05 -05:00
parent a9a5e52a23
commit 3dd6894305
3 changed files with 12 additions and 34 deletions

View File

@@ -6,19 +6,15 @@
#include <iomanip>
static void write_closed_message(Channel *ch, StreamBuffer *out) {
eng::ostringstream oss;
oss << "Chan " << ch->chid() << " closed [" << ch->error() << "]\n";
out->write_bytes(oss.str());
static void write_closed_message(Channel *ch) {
util::dprint("Chan ", ch->chid(), " closed [", ch->error(), "]\n");
}
static void dump_lines(StreamBuffer *in, StreamBuffer *out, int chid) {
static void dump_lines(StreamBuffer *in, int chid) {
while (true) {
eng::string l = in->readline();
if (l == "") break;
eng::ostringstream oss;
oss << "Chan " << chid << ": " << l;
out->write_bytes(oss.str());
util::dprint("Chan ", chid, ": ", l);
}
}
@@ -34,13 +30,11 @@ public:
}
virtual void event_update() override {
SharedChannel stdioch = get_stdio_channel();
dump_lines(stdioch->in(), stdioch->out(), 0);
eng::vector<SharedChannel> keep;
for (SharedChannel &ch : channels_) {
dump_lines(ch->in(), stdioch->out(), ch->chid());
dump_lines(ch->in(), ch->chid());
if (ch->closed()) {
write_closed_message(ch.get(), stdioch->out());
write_closed_message(ch.get());
} else {
keep.emplace_back(std::move(ch));
}
@@ -60,13 +54,11 @@ public:
}
virtual void event_update() override {
SharedChannel stdioch = get_stdio_channel();
dump_lines(stdioch->in(), stdioch->out(), 0);
eng::vector<SharedChannel> keep;
for (SharedChannel &ch : channels_) {
dump_lines(ch->in(), stdioch->out(), ch->chid());
dump_lines(ch->in(), ch->chid());
if (ch->closed()) {
write_closed_message(ch.get(), stdioch->out());
write_closed_message(ch.get());
} else {
keep.emplace_back(std::move(ch));
}