Improve Events API

If the call is interrupted by a signal, this will throw, which we clearly do not want. Simplifying the API to let the user decide what to do on error is probably the best option.
This commit is contained in:
Giulio Eulisse 2021-05-04 09:57:28 +02:00 committed by Dennis Klein
parent 868fe02ee9
commit 6dfea32aee
3 changed files with 5 additions and 9 deletions

View File

@ -56,7 +56,7 @@ class FairMQSocket
/// If the backend supports it, fills the unsigned integer @a events with the ZMQ_EVENTS value /// If the backend supports it, fills the unsigned integer @a events with the ZMQ_EVENTS value
/// DISCLAIMER: this API is experimental and unsupported and might be dropped / refactored in /// DISCLAIMER: this API is experimental and unsupported and might be dropped / refactored in
/// the future. /// the future.
virtual void Events(uint32_t* events) = 0; virtual int Events(uint32_t* events) = 0;
virtual void SetLinger(const int value) = 0; virtual void SetLinger(const int value) = 0;
virtual int GetLinger() const = 0; virtual int GetLinger() const = 0;
virtual void SetSndBufSize(const int value) = 0; virtual void SetSndBufSize(const int value) = 0;

View File

@ -378,12 +378,10 @@ class Socket final : public fair::mq::Socket
} }
} }
void Events(uint32_t* events) override int Events(uint32_t* events) override
{ {
size_t eventsSize = sizeof(uint32_t); size_t eventsSize = sizeof(uint32_t);
if (zmq_getsockopt(fSocket, ZMQ_EVENTS, events, &eventsSize) < 0) { return zmq_getsockopt(fSocket, ZMQ_EVENTS, events, &eventsSize);
throw SocketError(tools::ToString("failed setting ZMQ_EVENTS, reason: ", zmq_strerror(errno)));
}
} }
int GetLinger() const override int GetLinger() const override

View File

@ -323,12 +323,10 @@ class Socket final : public fair::mq::Socket
} }
} }
void Events(uint32_t* events) override int Events(uint32_t* events) override
{ {
size_t eventsSize = sizeof(uint32_t); size_t eventsSize = sizeof(uint32_t);
if (zmq_getsockopt(fSocket, ZMQ_EVENTS, events, &eventsSize) < 0) { return zmq_getsockopt(fSocket, ZMQ_EVENTS, events, &eventsSize);
throw SocketError(tools::ToString("failed setting ZMQ_EVENTS, reason: ", zmq_strerror(errno)));
}
} }
void SetLinger(const int value) override void SetLinger(const int value) override