Skip to content

Conversation

@hown3d
Copy link

@hown3d hown3d commented Jan 16, 2026

Support canceling ringbuf epoll using a context.

Signed-off-by: Lukas Hoehl <lukas.hoehl@stackit.cloud>
@hown3d hown3d requested review from a team and florianl as code owners January 16, 2026 17:25
Signed-off-by: Lukas Hoehl <lukas.hoehl@stackit.cloud>
// Returns [os.ErrDeadlineExceeded] if a deadline was set and no wakeup was received.
// Returns [ErrFlushed] if the ring buffer was flushed manually.
// Returns [os.ErrClosed] if the poller was closed.
func (p *poller) Wait(deadline time.Time) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you elaborate more a bit on why this change is needed for your case?

As you show, with SetDeadline() in on of the tests, a similar behaviour can be achieved.

Copy link
Author

@hown3d hown3d Jan 16, 2026

Choose a reason for hiding this comment

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

My use case would be to stop blocking if a context, e.g. from a http request, is canceled.

I found the SetDeadline() function a bit misleading for that use case, because then the application would need to handle the context cancel correctly and use the function with time.Now().
Passing contexts down to subfunction calls felt easier instead of handling it on the application side.

Maybe there is a better take to handle this, I am open for discussion :)

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