Results 1 to 4 of 4

Thread: Thread Synchronization for specific thread

  1. #1
    Join Date
    Jan 2012
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Thread Synchronization for specific thread

    Hi!
    I am working on multithreaded project which is almost done, but now I want to use CUDA SDK which is dependent on thread it runs in.
    So, basically what I want is to create object (let's call it CUDAObject) for all work with CUDA, which will "live" in its own thread and use this CUDAObject for execution of CUDA functions. I do not want to rewrite most of my project, so what I need is some mechanism of executing CUDA code in CUDAObject.
    What I was about to do was to emit signals (from different objects in different threads) which are connected using queued connection to CUDA object and then somehow wait for the slot in CUDAObject to finish its execution.
    Firstly I was about to do it using QMutexes, but they must be locked and unlocked in the same thread. Then I looked into QFuture, which sadly looks like it is dependent on QtConcurent, which runs in different thread. So, I would like to know, if there is a way to wait until the slot in the CUDAObject is finished. Can anyone help me?

  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: Thread Synchronization for specific thread

    Ok but what exactly do you want to protect using a mutex (or whatever else mechanism you would choose)?
    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
    Jan 2012
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Thread Synchronization for specific thread

    I want to wait until the computation in CUDAObject finishes.

  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: Thread Synchronization for specific thread

    In that case use a wait condition (QWaitCondition).
    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. Replies: 1
    Last Post: 15th July 2011, 15:33
  2. thread synchronization
    By freekill in forum Qt Programming
    Replies: 10
    Last Post: 6th January 2010, 17:29
  3. Thread Synchronization Problem
    By sijithjames in forum Qt Programming
    Replies: 13
    Last Post: 13th November 2009, 14:53
  4. Replies: 16
    Last Post: 7th October 2009, 08:17
  5. Replies: 3
    Last Post: 30th June 2008, 15:23

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.