This project is read-only.

external event loop

Feb 3, 2014 at 10:08 PM
My apologies if this is the wrong place to post developer questions…

I would like to turn DBus ( events into an observable; eventually encapsulating all of DBus for Rx.cpp access. DBus has its own event loop (and thread) so I am not sure where to begin combining the DBus event loop with the Rx.cpp schedulers. If anyone has any suggestions or example libraries that I should look at, please let me know.

I don't have .NET access and the C++ examples for Rx.cpp seem a little sparse…

thanks for any help,
Feb 5, 2014 at 6:05 AM
The timeflieslikeanarrow sample in the repo shows a way to use a Subject to connect a Win32 message loop to an Observable. The same technique will work for DBus I expect.
Create a Subject (which is an Observer and an Observable). Pass the Observer to the event loop and have it call OnNext for each event. Pass the Observable to the clients that wish to subscribe to the events.
Given that threads are involved:
  • The OnNext/OnError/OnCompleted methods on the Subject must not be called at the same time. If more than one thread will use the same Subject’s Observer then a mutex must be used to serialize the calls.
  • The calls to OnNext/OnError/OnCompleted on subscribers to the Subject’s Observable will be run on the DBus event loop thread. Use an observe_on if they need to be moved to a different thread.
Feb 5, 2014 at 3:58 PM
Great, thanks! I've been trying to adapt the FromEventPattern in rx-winrt.hpp to DBus.