Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Threading STL Queue

Threading STL Queue

Scheduled Pinned Locked Moved C / C++ / MFC
c++data-structures
5 Posts 3 Posters 0 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.
  • R Offline
    R Offline
    RS Ratheesh
    wrote on last edited by
    #1

    Hi, I pushed some string values in to the STL Queue. Now i need to pop the values from that queue using thread in MFC application. Thanks, Ratheesh.

    CPalliniC M 2 Replies Last reply
    0
    • R RS Ratheesh

      Hi, I pushed some string values in to the STL Queue. Now i need to pop the values from that queue using thread in MFC application. Thanks, Ratheesh.

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      ratheeshnair123 wrote:

      I pushed some string values in to the STL Queue. Now i need to pop the values from that queue using thread in MFC application.

      Nice to know. And what is the question?

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
      [My articles]

      In testa che avete, signor di Ceprano?

      R 1 Reply Last reply
      0
      • CPalliniC CPallini

        ratheeshnair123 wrote:

        I pushed some string values in to the STL Queue. Now i need to pop the values from that queue using thread in MFC application.

        Nice to know. And what is the question?

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        R Offline
        R Offline
        RS Ratheesh
        wrote on last edited by
        #3

        Hi, i am using MFC application in this application i need to display the received messages from the server (may be a chance for receiving more than one messages at a time) i need to display the received and send messages in the Listbox. i tried it in normal way, but the UI getting freezed after some time. I can able to log that message. So i tried it in some other way, like using queue the received messages are added in the queue and at thet time timer is running and one thread will pop the pushed messages in to the ListBox. Using thread how can i get the pushed value? Thanks, Ratheesh.

        CPalliniC 1 Reply Last reply
        0
        • R RS Ratheesh

          Hi, i am using MFC application in this application i need to display the received messages from the server (may be a chance for receiving more than one messages at a time) i need to display the received and send messages in the Listbox. i tried it in normal way, but the UI getting freezed after some time. I can able to log that message. So i tried it in some other way, like using queue the received messages are added in the queue and at thet time timer is running and one thread will pop the pushed messages in to the ListBox. Using thread how can i get the pushed value? Thanks, Ratheesh.

          CPalliniC Offline
          CPalliniC Offline
          CPallini
          wrote on last edited by
          #4

          You should add the messages to the queue using a worker thread, then notify it to the GUI thread (using, for instance PostMessage). The GUI thread eventually pops messages from the queue and displays them. of course you've to lock in same way queue access. :)

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          In testa che avete, signor di Ceprano?

          1 Reply Last reply
          0
          • R RS Ratheesh

            Hi, I pushed some string values in to the STL Queue. Now i need to pop the values from that queue using thread in MFC application. Thanks, Ratheesh.

            M Offline
            M Offline
            Maximilien
            wrote on last edited by
            #5

            it's probably not safe AS-IS. (stl is not by design thread-safe) I suggest you implement a simple synchronization mechanism (see Thread Synchronization for Beginners[^] )

            This signature was proudly tested on animals.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups