Skip to content

Misc updates#15

Open
artificiel wants to merge 10 commits into
256dpi:masterfrom
artificiel:misc-updates
Open

Misc updates#15
artificiel wants to merge 10 commits into
256dpi:masterfrom
artificiel:misc-updates

Conversation

@artificiel
Copy link
Copy Markdown

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
Copy Markdown
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