DrivenEngine channels are now shared_ptr
This commit is contained in:
@@ -23,23 +23,23 @@ static void dump_lines(StreamBuffer *in, StreamBuffer *out, int chid) {
|
||||
// You can type lines and see them echoed.
|
||||
class DriverListenTest : public DrivenEngine {
|
||||
public:
|
||||
std::vector<UniqueChannel> channels_;
|
||||
std::vector<SharedChannel> channels_;
|
||||
virtual void event_init(int argc, char *argv[]) {
|
||||
listen_port(8085);
|
||||
}
|
||||
|
||||
virtual void event_update() {
|
||||
while (true) {
|
||||
UniqueChannel ch = new_incoming_channel();
|
||||
SharedChannel ch = new_incoming_channel();
|
||||
if (ch == nullptr) break;
|
||||
ch->set_readline(true);
|
||||
channels_.emplace_back(std::move(ch));
|
||||
}
|
||||
|
||||
Channel *stdioch = get_stdio_channel();
|
||||
SharedChannel stdioch = get_stdio_channel();
|
||||
dump_lines(stdioch->in(), stdioch->out(), 0);
|
||||
std::vector<UniqueChannel> keep;
|
||||
for (UniqueChannel &ch : channels_) {
|
||||
std::vector<SharedChannel> keep;
|
||||
for (SharedChannel &ch : channels_) {
|
||||
dump_lines(ch->in(), stdioch->out(), ch->chid());
|
||||
if (ch->closed()) {
|
||||
write_closed_message(ch.get(), stdioch->out());
|
||||
@@ -55,18 +55,18 @@ public:
|
||||
// the output from the server.
|
||||
class DriverWebServerTest : public DrivenEngine {
|
||||
public:
|
||||
std::vector<UniqueChannel> channels_;
|
||||
std::vector<SharedChannel> channels_;
|
||||
virtual void event_init(int argc, char *argv[]) {
|
||||
UniqueChannel ch = new_outgoing_channel("stanford.edu:80");
|
||||
SharedChannel ch = new_outgoing_channel("stanford.edu:80");
|
||||
ch->out()->write_bytes("GET http://stanford.edu/index.html HTTP/1.1\n\n");
|
||||
channels_.emplace_back(std::move(ch));
|
||||
}
|
||||
|
||||
virtual void event_update() {
|
||||
Channel *stdioch = get_stdio_channel();
|
||||
SharedChannel stdioch = get_stdio_channel();
|
||||
dump_lines(stdioch->in(), stdioch->out(), 0);
|
||||
std::vector<UniqueChannel> keep;
|
||||
for (UniqueChannel &ch : channels_) {
|
||||
std::vector<SharedChannel> keep;
|
||||
for (SharedChannel &ch : channels_) {
|
||||
dump_lines(ch->in(), stdioch->out(), ch->chid());
|
||||
if (ch->closed()) {
|
||||
write_closed_message(ch.get(), stdioch->out());
|
||||
@@ -81,18 +81,18 @@ public:
|
||||
// This test produces a DNS resolution failure.
|
||||
class DriverDNSFailTest : public DrivenEngine {
|
||||
public:
|
||||
std::vector<UniqueChannel> channels_;
|
||||
std::vector<SharedChannel> channels_;
|
||||
virtual void event_init(int argc, char *argv[]) {
|
||||
UniqueChannel ch = new_outgoing_channel("akjsdkajshdakjshd.alk:80");
|
||||
SharedChannel ch = new_outgoing_channel("akjsdkajshdakjshd.alk:80");
|
||||
ch->out()->write_bytes("GET http://stanford.edu/index.html HTTP/1.1\n\n");
|
||||
channels_.emplace_back(std::move(ch));
|
||||
}
|
||||
|
||||
virtual void event_update() {
|
||||
Channel *stdioch = get_stdio_channel();
|
||||
SharedChannel stdioch = get_stdio_channel();
|
||||
dump_lines(stdioch->in(), stdioch->out(), 0);
|
||||
std::vector<UniqueChannel> keep;
|
||||
for (UniqueChannel &ch : channels_) {
|
||||
std::vector<SharedChannel> keep;
|
||||
for (SharedChannel &ch : channels_) {
|
||||
dump_lines(ch->in(), stdioch->out(), ch->chid());
|
||||
if (ch->closed()) {
|
||||
write_closed_message(ch.get(), stdioch->out());
|
||||
|
||||
Reference in New Issue
Block a user