Hi,
1) I would like to know the how I can put an exclusive lock on wait using a condition variable ?
Given below is my attempt, it contains 4 questions.
Code:#include "boost/thread.hpp" int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); boost :: shared_mutex m1; boost :: condition_variable_any c1; //Do all the 3 locks below behave like scoped_lock (will they get unlocked when they go out of scope) ? boost :: shared_lock<boost :: shared_mutex> l1(m1); //Shared Access boost :: upgrade_lock<boost :: shared_mutex> l2(m1); //2) Is this read lock ? no other thread can read ? boost :: upgrade_to_unique_lock<boost :: shared_mutex> l3(l2); //Exclusive Access c1.wait(l3); //Throws an error, how would I be able to put the l3 on wait ? //3) Also when I do so, what happens to l2, will it also be unlocked when l3 is put on wait ?? //4) Can I create l3 without creating l2 ? //I would like to put l3 on wait, so that what ever lock established is revoked, and when notified it can get the lock back. //5) How would I be able to achieve this ? return(0); }




Reply With Quote