Page 2 of 2 FirstFirst 12
Results 21 to 26 of 26

Thread: Thread Safe Queue container....

  1. #21
    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 Safe Queue container....

    Quote Originally Posted by kevinp View Post
    wysota, Thanks for your example! Just when I think I'm understanding it, a puzzle: At the end of tryDequeue(), shouldn't it be _semFree.release() instead of _semUsed.release() to note 1 less item in the queue, as in dequeue()?
    No. _semFree is released when dequeue() is called. The point of releasing _semUsed is that first you try to acquire it at the beginning of the method to make sure the queue is not empty so then you have to release the lock at the end of the method.
    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.


  2. #22
    Join Date
    Oct 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Thread Safe Queue container....

    Is the threadsafequeue.tar.gz link still valid for other people? I just tried to download it and am unable to untar it:
    Qt Code:
    1. luke@ThinkPad-W510:/tmp$ tar xvf threadsafequeue.tar.gz
    2. tar: This does not look like a tar archive
    3. tar: Skipping to next header
    4. tar: Exiting with failure status due to previous errors
    To copy to clipboard, switch view to plain text mode 

    Also, the file size when I download it is 990 bytes, but the forum post lists it as 960 bytes.... Anybody else having this issue?

  3. #23
    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 Safe Queue container....

    It is tar-gzipped.
    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.


  4. #24
    Join Date
    Oct 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Thread Safe Queue container....

    Quote Originally Posted by wysota View Post
    It is tar-gzipped.
    I am aware that it is tar-gzipped, and I am familiar with working with .tar.gz/.tgz files. `tar xvf` normally gunzips then untars tar-gzipped files just fine, but not this one. To get it to work, I had to do those things in two steps:
    Qt Code:
    1. $ gunzip threadsafequeue.tar.gz
    2. $ tar x -f threadsafequeue.tar
    To copy to clipboard, switch view to plain text mode 

    Which is unusual. Adding the -z option to tar did not fix it either.

  5. #25
    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 Safe Queue container....

    Quote Originally Posted by hazelnusse View Post
    `tar xvf` normally gunzips then untars tar-gzipped files just fine
    Does it? I was always sure -z option to tar is responsible for ungzipping.

    Adding the -z option to tar did not fix it either.
    The file was probably gzipped twice, don't ask me how.
    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.


  6. #26
    Join Date
    Jun 2011
    Posts
    1
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Thread Safe Queue container....

    FYI, in the copy of wysota's otherwise excellent ThreadSafeQueue that i downloaded, the return statement is missing from head().

    perhaps it has been fixed later and i missed the later version.

    thanks.

Similar Threads

  1. Is a QProcess thread safe in Qt4?
    By Jay_D in forum Qt Programming
    Replies: 4
    Last Post: 1st September 2009, 16:38
  2. What makes something not thread safe?
    By tgreaves in forum Newbie
    Replies: 9
    Last Post: 20th February 2009, 20:16
  3. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  4. Replies: 10
    Last Post: 20th March 2007, 22:19
  5. Are QHttp n QHttpRequestHeader thread safe?
    By Shambhavi in forum Qt Programming
    Replies: 4
    Last Post: 21st January 2006, 08:33

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.