Skip to content

Conversation

xemul
Copy link
Contributor

@xemul xemul commented Aug 1, 2025

The member in question is initialized with eventfd descriptor and is then used by reactor to wakeup backend from sleep. The writeable_eventfd class provides "compatible" signalling facility that can be re-used.

The reading part of writeable_eventfd is readable_eventfd, which is too much for the backend usage, so the writeable_eventfd::consume() helper is added. Next, the read-side of the eventfd nowdays works via fd_kernel_completion-s inheritants, that are patched to call the newly introduced method.

In the end of the day, the patch generalizes the "protocol" that notify eventfd peers use to kick each other -- the 8 bytes dummy tranfer.

The member in question is initialized with eventfd descriptor and is
then used by reactor to wakeup backend from sleep. The writeable_eventfd
class provides "compatible" signalling facility that can be re-used.

The reading part of writeable_eventfd is readable_eventfd, which is too
much for the backend usage, so the writeable_eventfd::consume() helper
is added. Next, the read-side of the eventfd nowdays works via
fd_kernel_completion-s inheritants, that are patched to call the newly
introduced method.

In the end of the day, the patch generalizes the "protocol" that notify
eventfd peers use to kick each other -- the 8 bytes dummy tranfer.

Signed-off-by: Pavel Emelyanov <[email protected]>
@xemul xemul requested a review from avikivity August 1, 2025 17:00
std::optional<size_t> writeable_eventfd::consume() {
uint64_t c;
return _fd.read(&c, sizeof(c));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be part of the read side?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The read-side uses await-able wrapper around pollable_fd, which is not needed by the users of this new method. Actually the writeable_eventfd and readable_eventfd are supposed to play with each other, while reactor only needs the writeable end. I'll think on it a bit more

@xemul xemul marked this pull request as draft August 5, 2025 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants