zeromq / netmq

A 100% native C# implementation of ZeroMQ for .NET
Other
2.95k stars 744 forks source link

Support cancellation tokens everywhere where you can set a timeout #855

Closed erndob closed 2 years ago

erndob commented 4 years ago

Currently CancellationToken is not supported, which is an issue if you are trying to handle a shut down of a service. At the moment you are forced to make the timeouts short enough to catch the canceled token in between requests, but it would work a lot better if instead of just timeout, CancelationToken itself would be accepted too.

I could try implementing this if you agree.

somdoron commented 4 years ago

I'm not sure it is possible to implement the cancellation tokens. NetMQ is using sockets (file descriptors) and select for signaling. To use cancellation token you would have to get a handle that can be used in a select operation.

erndob commented 4 years ago

@somdoron You are right. I've quickly had a look at NetMQSelector, saw some timeout logic in an infinite loop and assumed it can be handled there.

somdoron commented 4 years ago

Ok, you would still have to use some timeout, like half a second to query the token.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had activity for 365 days. It will be closed if no further activity occurs within 56 days. Thank you for your contributions.