Important: Please read the Qt Code of Conduct -

Internal data exchange through threads with topic

  • Hello,

    I work on an application connect to a server for receive a data feed and transfert to right Widget/Data model for display it on screen.
    I wonder if i do it right or not, please evaluate me or give me a better solution.


    • ~500,000feed available on server which can be selected through an subscribing system
    • One client actually process ~1000 feed at the same time
    • One feed publish rate is around 3ms
    • There is three event loop (thread)
      • Socket managing and unserialization
      • Background data processing
      • Main (UI) event loop
    • Some QWidget aggregate several feed, some widget only read one feed

    My solution:

    The main idea is to introduce a FeedProxy class instance per feed

    1. Subscribe:

      1. QWidget retrieve from a singleton invokable FeedRegister the needed FeedProxy
      2. QWidget connect to SIGNAL(onNewFeed(FeedType)) on each proxy
      3. FeedProxy catch the connect through connectNotify and send feed subscription to server if not yet done
    2. Unsubscribe:

      1. QWidget disconnect from FeedHandler
      2. FeedHandler catch disconnectNotify and unsubscribe from server when isSignalConnected return false.
      3. Emit an SIGNAL(isOrphan) to FeedRegister for release FeedHandler instance
    3. Good points:

      • Use of INVOKE and signal/slot permit to work in differents threads
    4. Bad points:

      • Maybe need a garbage collector for unconnected feeds
      • Use of connectNotify, disconnectNotify and isSignalConnected violates the object-oriented principle of modularity.