[test/signals] trying test thread safe signals with the boost unit test framework

Hi guys,
Using the boost unit test framework, I'm trying to test a simple
scenario: when a person's name is set, their 'updated' signal is
triggered.
Here's my person class:
class person
{
public:
person() : name_() {};
void name(const std::string & name)
{
name_ = name;
updated(*this);
};
boost::signal

AMDG Richard Dingwall wrote:
person subject; mock_handler handler(subject);
subject.updated.connect(handler);
Unfortunately, when this code runs, it produces the following output:
<snip>
I'm not sure what's going on here, or why mock_handler's destructor is being called 4 extra times.
Can anyone shed some light as to why this might be happening?
The handler is being copied. To prevent this try using boost::ref subject.updated.connect(boost::ref(handler)); In Christ, Steven Watanabe

On Sun, Jun 8, 2008 at 12:56 AM, Steven Watanabe
The handler is being copied. To prevent this try using boost::ref
subject.updated.connect(boost::ref(handler));
Ah. I thought it might be something along those lines. It works perfectly now; thanks Steven! Richard
participants (2)
-
Richard Dingwall
-
Steven Watanabe