diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
commit | 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch) | |
tree | e5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/boost/libs/signals2/example/ordering_slots.cpp | |
parent | Initial commit. (diff) | |
download | ceph-upstream.tar.xz ceph-upstream.zip |
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/signals2/example/ordering_slots.cpp')
-rw-r--r-- | src/boost/libs/signals2/example/ordering_slots.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/boost/libs/signals2/example/ordering_slots.cpp b/src/boost/libs/signals2/example/ordering_slots.cpp new file mode 100644 index 00000000..f69bc182 --- /dev/null +++ b/src/boost/libs/signals2/example/ordering_slots.cpp @@ -0,0 +1,62 @@ +// Ordered slots hello world example for Boost.Signals2 +// Copyright Douglas Gregor 2001-2004. +// Copyright Frank Mori Hess 2009. +// +// Use, modification and +// distribution is subject to the Boost Software License, Version +// 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// For more information, see http://www.boost.org + +#include <iostream> +#include <boost/signals2/signal.hpp> + +struct Hello +{ + void operator()() const + { + std::cout << "Hello"; + } +}; + +struct World +{ + void operator()() const + { + std::cout << ", World!" << std::endl; + } +}; + +//[ good_morning_def_code_snippet +struct GoodMorning +{ + void operator()() const + { + std::cout << "... and good morning!" << std::endl; + } +}; +//] + +int main() +{ +//[ hello_world_ordered_code_snippet + boost::signals2::signal<void ()> sig; + + sig.connect(1, World()); // connect with group 1 + sig.connect(0, Hello()); // connect with group 0 +//] + +//[ hello_world_ordered_invoke_code_snippet + // by default slots are connected at the end of the slot list + sig.connect(GoodMorning()); + + // slots are invoked this order: + // 1) ungrouped slots connected with boost::signals2::at_front + // 2) grouped slots according to ordering of their groups + // 3) ungrouped slots connected with boost::signals2::at_back + sig(); +//] + + return 0; +} + |