]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/signals2/example/extended_slot.cpp
1 // Example program for connecting an extended slot,
2 // using a signal's connect_extended and extended_slot_type.
4 // Copyright Frank Mori Hess 2009.
6 // Use, modification and
7 // distribution is subject to the Boost Software License, Version
8 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
10 // For more information, see http://www.boost.org
12 #include <boost/signals2/signal.hpp>
16 namespace bs2
= boost::signals2
;
18 void single_shot_slot(const bs2::connection
&conn
, const std::string
&message
)
26 typedef bs2::signal
<void (void)> sig_type
;
29 sig_type::extended_slot_type
hello(&single_shot_slot
, _1
, "Hello");
30 sig
.connect_extended(hello
);
32 sig(); // prints "Hello"
34 sig_type::extended_slot_type
world(&single_shot_slot
, _1
, ", World!\n");
35 sig
.connect_extended(world
);
37 sig(); // only prints ", World!\n" since hello slot has disconnected itself
38 sig(); // prints nothing, world slot has disconnected itself