Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Internal data exchange through threads with topic
Forum Updated to NodeBB v4.3 + New Features

Internal data exchange through threads with topic

Scheduled Pinned Locked Moved Unsolved General and Desktop
signal & slotqthreadthread
2 Posts 2 Posters 973 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lvjp
    wrote on last edited by
    #1

    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.

    Problem:

    • ~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.
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What about doing the subscription related stuff in your proxy ? Basically two methods:

      1. FeedProxy::subscribe(YouCoolClass *)
      2. FeedProxy::unsubscribe(YouCoolClass *)

      No need for any special detection and you know exactly where things are happening.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved