#include "base/message_loop/message_pump_epoll.h"
#include <sys/eventfd.h>
#include <cstddef>
#include <cstdint>
#include <optional>
#include <utility>
#include "base/auto_reset.h"
#include "base/check_op.h"
#include "base/feature_list.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/metrics/histogram_macros.h"
#include "base/numerics/safe_conversions.h"
#include "base/posix/eintr_wrapper.h"
#include "base/ranges/algorithm.h"
#include "base/threading/thread_checker.h"
#include "base/time/time.h"
#include "base/trace_event/base_tracing.h"
namespace base {
namespace {
BASE_FEATURE(…);
std::atomic_bool g_use_batched_version = …;
std::atomic_bool g_use_poll = …;
constexpr std::pair<uint32_t, short int> kEpollToPollEvents[] = …;
void SetEventsForPoll(const uint32_t epoll_events, struct pollfd* poll_entry) { … }
}
struct MessagePumpEpoll::InterestParams { … };
class MessagePumpEpoll::Interest : public RefCounted<Interest> { … };
MessagePumpEpoll::MessagePumpEpoll() { … }
MessagePumpEpoll::~MessagePumpEpoll() = default;
void MessagePumpEpoll::InitializeFeatures() { … }
bool MessagePumpEpoll::WatchFileDescriptor(int fd,
bool persistent,
int mode,
FdWatchController* controller,
FdWatcher* watcher) { … }
void MessagePumpEpoll::Run(Delegate* delegate) { … }
void MessagePumpEpoll::RecordPeriodicMetrics() { … }
void MessagePumpEpoll::Quit() { … }
void MessagePumpEpoll::ScheduleWork() { … }
void MessagePumpEpoll::ScheduleDelayedWork(
const Delegate::NextWorkInfo& next_work_info) { … }
void MessagePumpEpoll::AddEpollEvent(EpollEventEntry& entry) { … }
void MessagePumpEpoll::UpdateEpollEvent(EpollEventEntry& entry) { … }
void MessagePumpEpoll::StopEpollEvent(EpollEventEntry& entry) { … }
void MessagePumpEpoll::UnregisterInterest(
const scoped_refptr<Interest>& interest) { … }
bool MessagePumpEpoll::WaitForEpollEvents(TimeDelta timeout) { … }
std::vector<struct pollfd>::iterator MessagePumpEpoll::FindPollEntry(int fd) { … }
void MessagePumpEpoll::RemovePollEntry(int fd) { … }
bool MessagePumpEpoll::GetEventsPoll(int epoll_timeout,
std::vector<epoll_event>* epoll_events) { … }
void MessagePumpEpoll::OnEpollEvent(EpollEventEntry& entry, uint32_t events) { … }
void MessagePumpEpoll::HandleEvent(int fd,
bool can_read,
bool can_write,
FdWatchController* controller) { … }
void MessagePumpEpoll::HandleWakeUp() { … }
void MessagePumpEpoll::BeginNativeWorkBatch() { … }
MessagePumpEpoll::EpollEventEntry::EpollEventEntry(int fd) : … { … }
MessagePumpEpoll::EpollEventEntry::~EpollEventEntry() { … }
uint32_t MessagePumpEpoll::EpollEventEntry::ComputeActiveEvents() const { … }
MessagePumpEpoll::FdWatchController::FdWatchController(
const Location& from_here)
: … { … }
MessagePumpEpoll::FdWatchController::~FdWatchController() { … }
bool MessagePumpEpoll::FdWatchController::StopWatchingFileDescriptor() { … }
const scoped_refptr<MessagePumpEpoll::Interest>&
MessagePumpEpoll::FdWatchController::AssignInterest(
const InterestParams& params) { … }
void MessagePumpEpoll::FdWatchController::ClearInterest() { … }
void MessagePumpEpoll::FdWatchController::OnFdReadable() { … }
void MessagePumpEpoll::FdWatchController::OnFdWritable() { … }
}