Boost logo

Boost Users :

Subject: [Boost-users] [Singals]problem about add a new connection in slot callback
From: mos (mmosquito_at_[hidden])
Date: 2009-08-07 00:04:23


Hi!
I'm afraid i can't discribe the problem very well, so please see the code:

#include <boost/signal.hpp>
#include <iostream>
using namespace std;
typedef boost::signal<void ()> signal_t;
typedef boost::signals::connection connection_t;

signal_t g_signal;

void test_b()
{
 cout << "b" << endl;
}

void test_a()
{
 cout << "a" << endl;
 g_signal.connect(test_b);
}

int _tmain(int argc, _TCHAR* argv[])
{
 connection_t t = g_signal.connect(test_a);
 g_signal();
 t.disconnect();
 g_signal();

 return 0;
}

int the function test_a , I perfer call test_b next signal that mean output is "a b"
but test_b is called immediately and the output is "a b b"

how can I solve the problem?

mos.



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