Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc updates #15

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Misc updates #15

wants to merge 9 commits into from

Conversation

artificiel
Copy link

a number of changes (1 per commit) culminating in thread support (I see it was once there and removed; we have a data-intensive app that benefits from mosquitto's own thread; it works for us with > 500 messages per second).

the previous implementation processed a single MQTT Message per update cycle. if things are coming in fast, a backlog accumulates. this mechanism re-triggers update if a message was received.

the example app has been augmented with some key functions; hit '2' to set the framerate to 2, it will exacerbate the behaviour. it 's' to toggle between self-loop and "old school" updates, and use 'b' to send bursts. when running at fps=2 and self_loop = false, the queueing behavior is evident.
the ofxThreadedMQTT class implements the native mosquitto pthread support, and provides a thread-safe threadChannel interface to the messages.

The class hierarchy is preferred to a constructor/setup variable as these bool are opaque and not self-documenting. A class named ofxThreadedMQTT is self-documenting (and the possible feature of live-toggling between threaded and non-threaded is probably not useful as the 2 approaches are no so directly compatible).

The upcoming mosquitto 2.1 supports the threads on Windows (currently only POSIX).

An example is provided.
@artificiel
Copy link
Author

NOTE: this threading implementation maintains the notification callbacks for online/offline state change; this can possibly not be thread-safe (but it hasn't bitten us). an additional "administrative" threadChannel could be used to synchronize these in parallel to the actual messages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants