
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? Thanks for any help.

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?
Thanks for any help.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Hi, look for 'Blocking Slots (Beginner)' in http://boost.org/doc/html/signals/tutorial.html#id2732772 -- HTH dave

-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of David Klein Sent: Wednesday, February 14, 2007 9:43 AM To: boost-users@lists.boost.org Subject: Re: [Boost-users] How to block a signal Dahman wrote:
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?
Thanks for any help. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
look for 'Blocking Slots (Beginner)' in http://boost.org/doc/html/signals/tutorial.html#id2732772 -- HTH dave [Nat] But that seems to require retaining each connection, which the OP says he doesn't have. Is there an operation to block the /signal/ versus individual /slots/?

look for 'Blocking Slots (Beginner)' in http://boost.org/doc/html/signals/tutorial.html#id2732772
-- HTH dave
[Nat] But that seems to require retaining each connection, which the OP says he doesn't have. Is there an operation to block the /signal/ versus individual /slots/?
Exactly! A function like signal.block() and signal.unblock() witch block and unblock all the connections. Thanks

Nat Goodspeed wrote:
[Nat] But that seems to require retaining each connection, which the OP says he doesn't have. Is there an operation to block the /signal/ versus individual /slots/?
There is a loophole: You can set a combiner that simply doesn't dereference any iterators and thus doesn't call any slots. But I don't think that's a recommended solution. The question is: If you don't have control over the signal's invo- cation (if you do, you don't need to block it - just don't call it), should you be able to block it? I think not. Regards Timmo Stange

Nat Goodspeed wrote:
[Nat] But that seems to require retaining each connection, which the OP says he doesn't have. Is there an operation to block the /signal/ versus individual /slots/? _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
*blush* Oh sorry, i guess i read to fast. Blocking the signal doesn't seem to be possible, so i'd probably use a second signal, with the original one controlling the blocking. -- Regards, dave

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

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
participants (5)
-
Dahman
-
David Klein
-
Johan Råde
-
Nat Goodspeed
-
Timmo Stange