qpid-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alan Conway <acon...@redhat.com>
Subject C++: API preference question - fallible queue APIs.
Date Mon, 05 Nov 2007 16:16:49 GMT
I can never make up my mind about which option to choose of the
following APIs:

Message get(Timeout); // return Message::none if we timed out.
bool get(Timeout, Message&); // Return true if we got a message

I sorta prefer the former but the latter makes it harder to
invadvertently ignore the possibility of timeout.

I don't like this one:
Message get(Timeout); // throw if timeout

because if you provide a get API with a timeout, that implies that
timing out is an expected possible outcome and throw is inappropriate.

I've no problem with

Message get(); // throw if timeout or unavailable.

Because in this case the user has no reason to expect a timeout so
exception is appropriate.


View raw message