Boost logo

Boost Users :

From: Timmo Stange (ts_at_[hidden])
Date: 2007-02-14 10:14:14


Dahman wrote:
> Hi,
> I have a signal with many slots connected to it and I have a class object witch
> want to have the possibility to block this signal at the start and unblock it
> later, but know nothing about what and how many slots are connected to it (then
> can't use connection.disconnect()).
>
> Is there any solution for this problem?

The easiest solution would be to use two signals:

signal0<void> initiator; // the signal that is emitted
signal0<void> broadcaster; // the signal that observers connect to

signals::connection control = initiator.connect(broadcaster);

// ... connect arbitrary number of slots to the broadcaster

control.block();
initiator(); // will not call any slots
control.unblock();
initiator(); // will call the slots

Regards

Timmo Stange


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