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 combine two eventloops into one?
Forum Updated to NodeBB v4.3 + New Features

How to combine two eventloops into one?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 932 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.
  • M Offline
    M Offline
    Mr Pang
    wrote on last edited by
    #1

    I want to develop a http/2 server using Qt5 + nghttp2.
    From the example given by nghttp2, I found that nghttp2 has its own eventloop.
    server.listen_and_serve(ec, addr, port) is very similar to app.exec() in Qt.
    Is it possible to handle both eventloop in a single thread?

    JonBJ J.HilkJ 2 Replies Last reply
    0
    • M Mr Pang

      I want to develop a http/2 server using Qt5 + nghttp2.
      From the example given by nghttp2, I found that nghttp2 has its own eventloop.
      server.listen_and_serve(ec, addr, port) is very similar to app.exec() in Qt.
      Is it possible to handle both eventloop in a single thread?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @Mr-Pang
      I admit I have no experience in this area so take with a pinch of salt, but until someone knowing better replies I would say not. If you need server.listen_and_serve() to run its own event loop that won't combine with the Qt loop, so it should run in its own thread?

      1 Reply Last reply
      1
      • M Mr Pang

        I want to develop a http/2 server using Qt5 + nghttp2.
        From the example given by nghttp2, I found that nghttp2 has its own eventloop.
        server.listen_and_serve(ec, addr, port) is very similar to app.exec() in Qt.
        Is it possible to handle both eventloop in a single thread?

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by J.Hilk
        #3

        @Mr-Pang

        I would say no, but I'm not 100% sure on this.

        Your situation actually seems to be one of the cases where Subclassing QThread and overwriting run() seems like the best option to do.

        That would also allow you to define signals to emit, to react to the state changes and responses etc.


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        1 Reply Last reply
        4
        • Kent-DorfmanK Offline
          Kent-DorfmanK Offline
          Kent-Dorfman
          wrote on last edited by Kent-Dorfman
          #4

          @Mr-Pang said in How to combine two eventloops into one?:

          nghttp2

          Anytime you link Qt with a library that has its own event loop you should run that library event loop in its own thread and do some thread to thread communications between the two frameworks. Let each exist independently within your program and have them communicate between each other. Trying to implement signal/slot in nghttp2 is probably a disaster waiting to happen, but you could create semaphores or message queues to ship data back and forth between the two framworks.

          Edit: BTW: some libraries recognize that you will use them in a framework that has its own event queue and will provide an explicit call to process messages in their own queue...such as a ficticious example: nghttp2::process_event_queue()

          1 Reply Last reply
          4

          • Login

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