Results 1 to 6 of 6

Thread: syncronous call function from other thread

  1. #1
    Join Date
    Aug 2010
    Posts
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default syncronous call function from other thread

    I have the GUI Qthread and n workers Qthreads. I'm looking the way to do a syncronous call to a function that lives and must run on the GUI thread from the workers (with the minimun delay) and blocks the worker thread until is complete (about 20 ms).

    With signals I've delays more than a second in process the signal. I try send events, but the call don't run on main thread.

    What can be the best way to do this?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: syncronous call function from other thread

    What signals semantics were you using? BlockingQueued?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: syncronous call function from other thread

    use Qt:: DirectConnection, while making a connection

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: syncronous call function from other thread

    Quote Originally Posted by Santosh Reddy View Post
    use Qt:: DirectConnection, while making a connection
    Then the slot will be executed in context of the worker thread and not the gui thread.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Aug 2010
    Posts
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: syncronous call function from other thread

    Now I implement it with two signals and two slots in Queued, one from worker to main, and when executed send another signal from main to worker to continue the work.

    With BlockingQueue sometimes one thread finish in deadlock.

    there any way to force the context??

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: syncronous call function from other thread

    If there is a deadlock then only because your code creates it, for example by doing a similar call the other way or blocking on a mutex.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Qt function call in vb.net
    By abghosh in forum Qt Programming
    Replies: 7
    Last Post: 6th March 2010, 17:00
  2. No Matching function to call...
    By weepdoo in forum Qt Programming
    Replies: 2
    Last Post: 7th November 2008, 17:30
  3. function call
    By Walsi in forum Qt Programming
    Replies: 3
    Last Post: 12th June 2007, 09:13
  4. Cannot call function without object
    By Salazaar in forum Newbie
    Replies: 5
    Last Post: 11th June 2007, 14:55
  5. Replies: 3
    Last Post: 16th May 2007, 11:07

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.