#include <grpc/support/port_platform.h>
#include "src/core/lib/event_engine/posix_engine/ev_poll_posix.h"
#include <stdint.h>
#include <atomic>
#include <initializer_list>
#include <list>
#include <memory>
#include <utility>
#include "absl/container/inlined_vector.h"
#include "absl/functional/any_invocable.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_format.h"
#include <grpc/event_engine/event_engine.h>
#include <grpc/status.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include <grpc/support/time.h>
#include "src/core/lib/event_engine/poller.h"
#include "src/core/lib/event_engine/posix_engine/event_poller.h"
#include "src/core/lib/event_engine/posix_engine/posix_engine_closure.h"
#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/memory.h"
#include "src/core/lib/iomgr/port.h"
#ifdef GRPC_POSIX_SOCKET_EV_POLL
#include <errno.h>
#include <limits.h>
#include <poll.h>
#include <sys/socket.h>
#include <unistd.h>
#include <grpc/support/alloc.h>
#include "src/core/lib/event_engine/common_closures.h"
#include "src/core/lib/event_engine/posix_engine/wakeup_fd_posix.h"
#include "src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.h"
#include "src/core/lib/event_engine/time_util.h"
#include "src/core/lib/gprpp/fork.h"
#include "src/core/lib/gprpp/global_config.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/gprpp/strerror.h"
#include "src/core/lib/gprpp/sync.h"
#include "src/core/lib/gprpp/time.h"
GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_poll_strategy);
static const intptr_t kClosureNotReady = …;
static const intptr_t kClosureReady = …;
static const int kPollinCheck = …;
static const int kPolloutCheck = …;
namespace grpc_event_engine {
namespace experimental {
Events;
class PollEventHandle : public EventHandle { … };
namespace {
std::list<PollPoller*> fork_poller_list;
PollEventHandle* fork_fd_list_head = …;
gpr_mu fork_fd_list_mu;
void ForkFdListAddHandle(PollEventHandle* handle) { … }
void ForkFdListRemoveHandle(PollEventHandle* handle) { … }
void ForkPollerListAddPoller(PollPoller* poller) { … }
void ForkPollerListRemovePoller(PollPoller* poller) { … }
int PollElapsedTimeToMillis(grpc_core::Timestamp start) { … }
bool InitPollPollerPosix();
void ResetEventManagerOnFork() { … }
bool InitPollPollerPosix() { … }
}
EventHandle* PollPoller::CreateHandle(int fd, absl::string_view ,
bool track_err) { … }
void PollEventHandle::OrphanHandle(PosixEngineClosure* on_done, int* release_fd,
absl::string_view ) { … }
int PollEventHandle::NotifyOnLocked(PosixEngineClosure** st,
PosixEngineClosure* closure) { … }
int PollEventHandle::SetReadyLocked(PosixEngineClosure** st) { … }
void PollEventHandle::ShutdownHandle(absl::Status why) { … }
void PollEventHandle::NotifyOnRead(PosixEngineClosure* on_read) { … }
void PollEventHandle::NotifyOnWrite(PosixEngineClosure* on_write) { … }
void PollEventHandle::NotifyOnError(PosixEngineClosure* on_error) { … }
void PollEventHandle::SetReadable() { … }
void PollEventHandle::SetWritable() { … }
void PollEventHandle::SetHasError() { … }
uint32_t PollEventHandle::BeginPollLocked(uint32_t read_mask,
uint32_t write_mask) { … }
bool PollEventHandle::EndPollLocked(bool got_read, bool got_write) { … }
void PollPoller::KickExternal(bool ext) { … }
void PollPoller::Kick() { … }
void PollPoller::PollerHandlesListAddHandle(PollEventHandle* handle) { … }
void PollPoller::PollerHandlesListRemoveHandle(PollEventHandle* handle) { … }
PollPoller::PollPoller(Scheduler* scheduler)
: … { … }
PollPoller::PollPoller(Scheduler* scheduler, bool use_phony_poll)
: … { … }
PollPoller::~PollPoller() { … }
Poller::WorkResult PollPoller::Work(
EventEngine::Duration timeout,
absl::FunctionRef<void()> schedule_poll_again) { … }
void PollPoller::Shutdown() { … }
PollPoller* MakePollPoller(Scheduler* scheduler, bool use_phony_poll) { … }
}
}
#else
#include "src/core/lib/gprpp/crash.h"
namespace grpc_event_engine {
namespace experimental {
PollPoller::PollPoller(Scheduler* ) {
grpc_core::Crash("unimplemented");
}
void PollPoller::Shutdown() { grpc_core::Crash("unimplemented"); }
PollPoller::~PollPoller() { grpc_core::Crash("unimplemented"); }
EventHandle* PollPoller::CreateHandle(int , absl::string_view ,
bool ) {
grpc_core::Crash("unimplemented");
}
Poller::WorkResult PollPoller::Work(
EventEngine::Duration ,
absl::FunctionRef<void()> ) {
grpc_core::Crash("unimplemented");
}
void PollPoller::Kick() { grpc_core::Crash("unimplemented"); }
PollPoller* MakePollPoller(Scheduler* ,
bool ) {
return nullptr;
}
void PollPoller::KickExternal(bool ) {
grpc_core::Crash("unimplemented");
}
void PollPoller::PollerHandlesListAddHandle(PollEventHandle* ) {
grpc_core::Crash("unimplemented");
}
void PollPoller::PollerHandlesListRemoveHandle(PollEventHandle* ) {
grpc_core::Crash("unimplemented");
}
}
}
#endif