|
|
|
@ -56,9 +56,9 @@ class AsyncConnect { |
|
|
|
|
public: |
|
|
|
|
AsyncConnect(EventEngine::OnConnectCallback on_connect, |
|
|
|
|
std::shared_ptr<EventEngine> engine, ThreadPool* executor, |
|
|
|
|
grpc_event_engine::posix_engine::EventHandle* fd, |
|
|
|
|
grpc_event_engine::experimental::EventHandle* fd, |
|
|
|
|
MemoryAllocator&& allocator, |
|
|
|
|
const grpc_event_engine::posix_engine::PosixTcpOptions& options, |
|
|
|
|
const grpc_event_engine::experimental::PosixTcpOptions& options, |
|
|
|
|
std::string resolved_addr_str, int64_t connection_handle) |
|
|
|
|
: on_connect_(std::move(on_connect)), |
|
|
|
|
engine_(engine), |
|
|
|
@ -80,15 +80,15 @@ class AsyncConnect { |
|
|
|
|
void OnWritable(absl::Status status) ABSL_NO_THREAD_SAFETY_ANALYSIS; |
|
|
|
|
|
|
|
|
|
grpc_core::Mutex mu_; |
|
|
|
|
grpc_event_engine::posix_engine::PosixEngineClosure* on_writable_ = nullptr; |
|
|
|
|
grpc_event_engine::experimental::PosixEngineClosure* on_writable_ = nullptr; |
|
|
|
|
EventEngine::OnConnectCallback on_connect_; |
|
|
|
|
std::shared_ptr<EventEngine> engine_; |
|
|
|
|
ThreadPool* executor_; |
|
|
|
|
EventEngine::TaskHandle alarm_handle_; |
|
|
|
|
int refs_{2}; |
|
|
|
|
grpc_event_engine::posix_engine::EventHandle* fd_; |
|
|
|
|
grpc_event_engine::experimental::EventHandle* fd_; |
|
|
|
|
MemoryAllocator allocator_; |
|
|
|
|
grpc_event_engine::posix_engine::PosixTcpOptions options_; |
|
|
|
|
grpc_event_engine::experimental::PosixTcpOptions options_; |
|
|
|
|
std::string resolved_addr_str_; |
|
|
|
|
int64_t connection_handle_; |
|
|
|
|
bool connect_cancelled_; |
|
|
|
@ -97,12 +97,12 @@ class AsyncConnect { |
|
|
|
|
// A helper class to manager lifetime of the poller associated with the
|
|
|
|
|
// posix event engine.
|
|
|
|
|
class PosixEnginePollerManager |
|
|
|
|
: public grpc_event_engine::posix_engine::Scheduler { |
|
|
|
|
: public grpc_event_engine::experimental::Scheduler { |
|
|
|
|
public: |
|
|
|
|
explicit PosixEnginePollerManager(std::shared_ptr<ThreadPool> executor); |
|
|
|
|
explicit PosixEnginePollerManager( |
|
|
|
|
grpc_event_engine::posix_engine::PosixEventPoller* poller); |
|
|
|
|
grpc_event_engine::posix_engine::PosixEventPoller* Poller() { |
|
|
|
|
grpc_event_engine::experimental::PosixEventPoller* poller); |
|
|
|
|
grpc_event_engine::experimental::PosixEventPoller* Poller() { |
|
|
|
|
return poller_; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -121,7 +121,7 @@ class PosixEnginePollerManager |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
enum class PollerState { kExternal, kOk, kShuttingDown }; |
|
|
|
|
grpc_event_engine::posix_engine::PosixEventPoller* poller_ = nullptr; |
|
|
|
|
grpc_event_engine::experimental::PosixEventPoller* poller_ = nullptr; |
|
|
|
|
std::atomic<PollerState> poller_state_{PollerState::kOk}; |
|
|
|
|
std::shared_ptr<ThreadPool> executor_; |
|
|
|
|
}; |
|
|
|
@ -155,7 +155,7 @@ class PosixEventEngine final : public EventEngine, |
|
|
|
|
// constructor directly. Instead use the MakeTestOnlyPosixEventEngine static
|
|
|
|
|
// method. Its expected to be used only in tests.
|
|
|
|
|
explicit PosixEventEngine( |
|
|
|
|
grpc_event_engine::posix_engine::PosixEventPoller* poller); |
|
|
|
|
grpc_event_engine::experimental::PosixEventPoller* poller); |
|
|
|
|
PosixEventEngine(); |
|
|
|
|
#else // GRPC_POSIX_SOCKET_TCP
|
|
|
|
|
PosixEventEngine(); |
|
|
|
@ -194,7 +194,7 @@ class PosixEventEngine final : public EventEngine, |
|
|
|
|
// event engine will also not attempt to shutdown the poller since it does not
|
|
|
|
|
// own it.
|
|
|
|
|
static std::shared_ptr<PosixEventEngine> MakeTestOnlyPosixEventEngine( |
|
|
|
|
grpc_event_engine::posix_engine::PosixEventPoller* test_only_poller) { |
|
|
|
|
grpc_event_engine::experimental::PosixEventPoller* test_only_poller) { |
|
|
|
|
return std::make_shared<PosixEventEngine>(test_only_poller); |
|
|
|
|
} |
|
|
|
|
#endif // GRPC_POSIX_SOCKET_TCP
|
|
|
|
@ -216,10 +216,10 @@ class PosixEventEngine final : public EventEngine, |
|
|
|
|
std::shared_ptr<PosixEnginePollerManager> poller_manager); |
|
|
|
|
|
|
|
|
|
ConnectionHandle ConnectInternal( |
|
|
|
|
grpc_event_engine::posix_engine::PosixSocketWrapper sock, |
|
|
|
|
grpc_event_engine::experimental::PosixSocketWrapper sock, |
|
|
|
|
OnConnectCallback on_connect, ResolvedAddress addr, |
|
|
|
|
MemoryAllocator&& allocator, |
|
|
|
|
const grpc_event_engine::posix_engine::PosixTcpOptions& options, |
|
|
|
|
const grpc_event_engine::experimental::PosixTcpOptions& options, |
|
|
|
|
Duration timeout); |
|
|
|
|
|
|
|
|
|
void OnConnectFinishInternal(int connection_handle); |
|
|
|
@ -233,7 +233,7 @@ class PosixEventEngine final : public EventEngine, |
|
|
|
|
TaskHandleSet known_handles_ ABSL_GUARDED_BY(mu_); |
|
|
|
|
std::atomic<intptr_t> aba_token_{0}; |
|
|
|
|
std::shared_ptr<ThreadPool> executor_; |
|
|
|
|
posix_engine::TimerManager timer_manager_; |
|
|
|
|
TimerManager timer_manager_; |
|
|
|
|
#ifdef GRPC_POSIX_SOCKET_TCP |
|
|
|
|
std::shared_ptr<PosixEnginePollerManager> poller_manager_; |
|
|
|
|
#endif // GRPC_POSIX_SOCKET_TCP
|
|
|
|
|