Boost logo

Boost Users :

Subject: Re: [Boost-users] scope_lock question
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2013-02-21 22:45:51


AMDG

On 02/21/2013 05:22 PM, Jeff Dunlap wrote:
> I plan to start using Boost Thread, but for now I have a multithreaded Win32
> application that does not use boost.
>
> Although the threads were not created with Boost Thread, can I use
> boost::mutex::scoped_lock to protect some new functions I write for the app?

Yes. Synchronization primitives should work
on any thread regardless of whether it was
started using Boost.Thread or not. (I should
point out that the main thread is never started
by Boost.Thread, so this /has/ to work.)

> Example:
>
>
> boost::mutex mutex;
>
> void whatever()
> {
> boost::mutex::scoped_lock lock(mutex);
> // will this be protected even though the
> // thread was not created using Boost?
> }
>

In Christ,
Steven Watanabe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net