refactor EiEventQueue remove anon enum for a few static members

This commit is contained in:
sithlord48 2025-07-08 13:57:40 -04:00 committed by Chris Rizzitello
parent 6ca980e3e5
commit 181d862838

View file

@ -49,23 +49,20 @@ void EiEventQueueBuffer::waitForEvent(double timeout_in_ms)
{ {
Thread::testCancel(); Thread::testCancel();
enum static const auto s_eiFd = 0;
{ static const auto s_pipeFd = 1;
EIFD, static const auto s_pollFdCount = 2;
PIPEFD,
POLLFD_COUNT, // Last element
};
struct pollfd pfds[POLLFD_COUNT]; struct pollfd pfds[s_pollFdCount];
pfds[EIFD].fd = ei_get_fd(m_ei); pfds[s_eiFd].fd = ei_get_fd(m_ei);
pfds[EIFD].events = POLLIN; pfds[s_eiFd].events = POLLIN;
pfds[PIPEFD].fd = m_pipeRead; pfds[s_pipeFd].fd = m_pipeRead;
pfds[PIPEFD].events = POLLIN; pfds[s_pipeFd].events = POLLIN;
int timeout = (timeout_in_ms < 0.0) ? -1 : static_cast<int>(1000.0 * timeout_in_ms); int timeout = (timeout_in_ms < 0.0) ? -1 : static_cast<int>(1000.0 * timeout_in_ms);
if (int retval = poll(pfds, POLLFD_COUNT, timeout); retval > 0) { if (int retval = poll(pfds, s_pollFdCount, timeout); retval > 0) {
if (pfds[EIFD].revents & POLLIN) { if (pfds[s_eiFd].revents & POLLIN) {
std::scoped_lock lock{m_mutex}; std::scoped_lock lock{m_mutex};
// libei doesn't allow ei_event_ref() because events are // libei doesn't allow ei_event_ref() because events are
@ -80,7 +77,7 @@ void EiEventQueueBuffer::waitForEvent(double timeout_in_ms)
} }
// the pipefd data doesn't matter, it only exists to wake up the thread // the pipefd data doesn't matter, it only exists to wake up the thread
// and potentially testCancel // and potentially testCancel
if (pfds[PIPEFD].revents & POLLIN) { if (pfds[s_pipeFd].revents & POLLIN) {
char buf[64]; char buf[64];
ssize_t total = 0; ssize_t total = 0;
ssize_t result; ssize_t result;