|Re: [paho-dev] Blocking "wait" in the C async library|
It presents a simpler means of synchronization, allows the client to block in an OS-independent way, and mimics the API of the MQTT client libraries in other languages. A wait() function as the sole blocking call is a common pattern in other modern asynchronous libraries: Microsoft Async, C++11 threads/futures. the Paho Java client library, etc. I'm not a GUI guy, I'm an RTOS guy, and do this pattern a lot, where a completed action always signals an OS synchronization object, but also fires an optional callback if the user requested it.
In particular, as I originally mentioned, I'm trying to make the C++ API mimic the Java one as much as possible, like:
mqtt::itoken tok = client.publish("some topic", myMessage);I can work around this in the C++ library by intercepting the callbacks, but two issues make this a little more complicated due to to the outgoing "send" thread in the C lib:
(1) There doesn't appear to be a way to get the MQTTAsync_token of a message when you send it. And thus it's difficult to tie a token to the message.
(2) Upon return of the send/sendMessage calls, the message has "disappeared" into the queue of the send thread. It doesn't appear in the list of outgoing messages (MQTTAsync_getPendingTokens) until some time later. So it is easy for the app to think that all messages were sent when some have yet to even be queued for transmission.
Thanks for your time,
On 05/20/2013 05:30 AM, Ian Craggs wrote:
Back to the top