Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[paho-dev] Blocking "wait" in the C async library

Well, while I'm throwing sand in the works, I might as well continue...

One thing that appears to be "missing" from the C async API is the ability to block a thread on a token while waiting for an action to complete. Something like:
int MQTTAsync_waitForCompletion(MQTTAsync handle, MQTTAsync_token token, int timeout);
This would prevent the app from wasting CPU cycles while spinning on a flag from a callback, and can simplify client apps that don't need the full power of a callback function by eliminating the need for them for basic synchronization. Plus it would allow the user to write more portable client apps, since the library would hide the OS-specific thread functionality.

It appears that the library already wraps condition variables in Linux. Maybe Windows could use a Manual Reset Event to do this?

Frank

Back to the top