I am using QBuffer in ReadWrite mode. One worker QThread pushes data in the buffer and another QThread reads from it.
Does QBuffer guarantee thread-safety or do I need to derive from QBuffer and add mutex stuff?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To quote Mark Summerfield’s book C++ GUI Programming with Qt 4:
Qt expects that you will use locking mechanisms around most of it’s classes. The docs will say “All functions are thread-safe” if they are, and the individual functions will also specify “is thread-safe”.
Because
QBufferis a direct subclass ofQIODeviceI would especially expect it not to be thread-safe, but there are container classes that are thread-safe for read-access, but would require locking for write access: