Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost.signals2] queries
From: Sean Farrow (sean.farrow_at_[hidden])
Date: 2011-02-21 10:42:01


Thanks just what I needed!
Cheers
Sean.

-----Original Message-----
From: boost-users-bounces_at_[hidden] [mailto:boost-users-bounces_at_[hidden]] On Behalf Of Igor R
Sent: 21 February 2011 15:32
To: boost-users_at_[hidden]
Subject: Re: [Boost-users] [boost.signals2] queries

> I am looking in to using boost.signals2 for a project I’m involved in, but
> have a few queries:
>
> Firstly, if I create a global signall:
>
>   boost::signals2::signal<void ()> sig;
>
> and then a structure:
>
> struct DoWork
>
> {
>
>   void operator()() const
>
>   {
>
> //work.
>
>   }
>
> If I then create a private member of a class:
>
> DoWork work;
>
> And then do:
>
> Sig.connect(Work);
>
> Will the connection happen on the thread in which the work member variable
> was defined or will a second thread be utilized?

Boost.Signals2 does not launch threads.

> Also given that sig will be a global and hence accessed from multiple
> threads, do I need a mutex?

signal instance is thread-safe - in the meaning that you can connect()
from one thread and signal from another, without explicit locking.
_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users


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