Skip to content

Commit

Permalink
enable detach & attach EventBase ops on folly::coro::Transport
Browse files Browse the repository at this point in the history
Summary:
The high-level goal here is to enable sychronously detaching current evb and attaching a new evb during an in-progress ReadCallback.

This diff adds a few things:
* Adds the necessary virtual functions for a supporting implementation to override
* Changes the visibility of member variables, namely EventBase and AsyncTransport, from private to protected. The overriding implementation will require access to these members to facilitate evb migration

Reviewed By: afrind

Differential Revision: D61883812

fbshipit-source-id: 42309f6f482094703df72e252ff5ab241a030c42
  • Loading branch information
hanidamlaj authored and facebook-github-bot committed Oct 9, 2024
1 parent 998ff0b commit 02547bf
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions folly/io/coro/Transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ class TransportIf {
virtual void closeWithReset() = 0;
virtual folly::AsyncTransport* getTransport() const = 0;
virtual const AsyncTransportCertificate* getPeerCertificate() const = 0;
virtual void detachEventBase() { LOG(FATAL) << "not implemented"; }
virtual void attachEventBase(folly::EventBase*) {
LOG(FATAL) << "not implemented";
}
};

class Transport : public TransportIf {
Expand Down Expand Up @@ -146,13 +150,15 @@ class Transport : public TransportIf {
return transport_->getPeerCertificate();
}

protected:
EventBase* eventBase_;
AsyncTransport::UniquePtr transport_;

private:
// non-copyable
Transport(const Transport&) = delete;
Transport& operator=(const Transport&) = delete;

EventBase* eventBase_;
AsyncTransport::UniquePtr transport_;
bool deferredReadEOF_{false};
};

Expand Down

0 comments on commit 02547bf

Please sign in to comment.