CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2008
    Posts
    2

    Boost Mutex locking

    Could some one please give me an example of how to explitly lock and unlock mutexs using the boost libarys because i cant seem to make it work.

    Thanks

  2. #2
    Join Date
    Nov 2003
    Posts
    1,902

    Re: Boost Mutex locking

    What did you try and what was the error?

    gg

  3. #3
    Join Date
    Jun 2002
    Location
    Stockholm, Sweden
    Posts
    1,641

    Re: Boost Mutex locking

    It depends on your Boost version, but you could try something like this.
    If you are using older Boost versions that don't have the lock/unlock functions there are some hacks that may help.

    Code:
    boost::mutex mymutex;
    
    void myprotectecfunction() {
      boost::mutex::scoped_lock mylock(mymutex, boost::defer_lock); // defer_lock makes it initially unlocked
      mylock.lock();
      mylock.unlock();
    }
    Nobody cares how it works as long as it works

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured