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. How to parse data to running thread ?
Forum Updated to NodeBB v4.3 + New Features

How to parse data to running thread ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 334 Views 1 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.
  • Q Offline
    Q Offline
    Qt embedded developer
    wrote on last edited by
    #1

    I have created once queue that shared betweeen back end and front end thread

    the front end thread is generated using sub class qthread.

    for time being i am creating dummy data in that same thread and push that data into queue.

    But Now i want to send data from c++ class to this running thread

    What are the possible ways to do this thing ?

    What is thread safe way to send data from c++ class to running qthread based sub class thread?

    sierdzioS 1 Reply Last reply
    0
    • Q Qt embedded developer

      I have created once queue that shared betweeen back end and front end thread

      the front end thread is generated using sub class qthread.

      for time being i am creating dummy data in that same thread and push that data into queue.

      But Now i want to send data from c++ class to this running thread

      What are the possible ways to do this thing ?

      What is thread safe way to send data from c++ class to running qthread based sub class thread?

      sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      @Qt-embedded-developer The safest and easiest way is to use signals and slots. Then Qt will handle all synchronization logic.
      If you want more customized solution, use standard thread syncing tools: mutexes, semaphores or if your data is very small - atomics.

      (Z(:^

      Q 1 Reply Last reply
      1
      • sierdzioS sierdzio

        @Qt-embedded-developer The safest and easiest way is to use signals and slots. Then Qt will handle all synchronization logic.
        If you want more customized solution, use standard thread syncing tools: mutexes, semaphores or if your data is very small - atomics.

        Q Offline
        Q Offline
        Qt embedded developer
        wrote on last edited by
        #3

        @sierdzio I have used signal and slot but my signal get emitted but slot is not get called

        QObject::connect(_messageSendPtr.data(), SIGNAL(sigData(QString)), _guiComPtr.data(), SLOT(slotData(QString)), Qt::QueuedConnection);

        what could be the reason?

        sierdzioS 1 Reply Last reply
        0
        • Q Qt embedded developer

          @sierdzio I have used signal and slot but my signal get emitted but slot is not get called

          QObject::connect(_messageSendPtr.data(), SIGNAL(sigData(QString)), _guiComPtr.data(), SLOT(slotData(QString)), Qt::QueuedConnection);

          what could be the reason?

          sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          @Qt-embedded-developer First: use functor based connections, they are much better.
          Second: check the result of connect - maybe it was not successful.
          Third: make the connection after you move the object to thread (if you do thread moving).

          (Z(:^

          1 Reply Last reply
          1
          • JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #5

            Duplicate https://forum.qt.io/topic/156213/what-should-be-best-mechanism-to-stop-and-start-same-thread-again

            It would be nice if you did not double post so people try to answer in two places.....

            1 Reply Last reply
            1
            • Christian EhrlicherC Christian Ehrlicher locked this topic on

            • Login

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