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. Sync call with timeout
Qt 6.11 is out! See what's new in the release blog

Sync call with timeout

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 484 Views
  • 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.
  • T Offline
    T Offline
    The Kid 77
    wrote on last edited by
    #1

    Hi all,

    I new to Qt and I'm facing a problem that I'm sure it is very simple for you dear experts.

    I want to obtain a synch call for a method that perform an async operation.
    I used mutex to serialize the call to the method and want the sync call to return either when the operation has been terminated or when a timeout expired. For the timeout control I'm using QTimer.

    I tried many solution, with different threads combination but I always get blocked for one of the following reasones:

    • The Qtimer thread affinity is not respected
    • The Qtimer's timeout is not delivered since it seems that the event loop is blocked due to different mutexed call.

    I have no code to provide in this instant but if it is needed I can redo one of my attemps and copy here. My belief, anyway is that it is not a matter of code, I need to understand how Qt works under the hood first. Am I rx?

    Could you please help me to understand how to architecture the solution in the correct way?

    Thanks in advance
    Best Regards

    jsulmJ 1 Reply Last reply
    0
    • T The Kid 77

      Hi all,

      I new to Qt and I'm facing a problem that I'm sure it is very simple for you dear experts.

      I want to obtain a synch call for a method that perform an async operation.
      I used mutex to serialize the call to the method and want the sync call to return either when the operation has been terminated or when a timeout expired. For the timeout control I'm using QTimer.

      I tried many solution, with different threads combination but I always get blocked for one of the following reasones:

      • The Qtimer thread affinity is not respected
      • The Qtimer's timeout is not delivered since it seems that the event loop is blocked due to different mutexed call.

      I have no code to provide in this instant but if it is needed I can redo one of my attemps and copy here. My belief, anyway is that it is not a matter of code, I need to understand how Qt works under the hood first. Am I rx?

      Could you please help me to understand how to architecture the solution in the correct way?

      Thanks in advance
      Best Regards

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @The-Kid-77 said in Sync call with timeout:

      with different threads

      Why threads? You want to make an assync function block, right?
      How do you know the assync operation has finished? Is there a callback or signal?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1

      • Login

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