Remove the concept of the 'stdio channel' from class DrivenEngine
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user