Boost logo

Boost Users :

From: Johan Råde (rade_at_[hidden])
Date: 2007-02-14 10:19:07


Timmo Stange wrote:
> 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

And you could encapsulate this as a class, blockable_signal.

--Johan


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