dead_slot_test.cpp |
run |
-Ensure that calling connect with a slot
+ | Ensure that calling connect with a slot
that has already expired does not actually
connect to the slot. |
|
diff --git a/doc/html/signals2/thread-safety.html b/doc/html/signals2/thread-safety.html
index cf10d5b354..88a72f17c3 100644
--- a/doc/html/signals2/thread-safety.html
+++ b/doc/html/signals2/thread-safety.html
@@ -1,3 +1,4 @@
+
@@ -26,13 +27,13 @@
The primary motivation for Boost.Signals2 is to provide a version of
the original Boost.Signals library which can be used safely in a
@@ -49,7 +50,7 @@
Each signal object default-constructs a Mutex
object to protect
its internal state. Furthermore, a Mutex
is created
@@ -61,7 +62,7 @@
signal's methods are called. The mutex is usually held until the
method completes, however there is one major exception to this rule. When
a signal is invoked by calling
- signal::operator()
,
+ signal::operator()
,
the invocation first acquires a lock on the signal's mutex. Then
it obtains a handle to the signal's slot list and combiner. Next
it releases the signal's mutex, before invoking the combiner to
@@ -108,7 +109,7 @@
Note that since we unlock the connection's mutex before executing
its associated slot, it is possible a slot will still be executing
after it has been disconnected by a
- connection::disconnect()
, if
+ connection::disconnect()
, if
the disconnect was called concurrently with signal invocation.
@@ -125,7 +126,7 @@
Future signal invocations will receive a handle to the newly created deep
copy of the slot list, and the old slot list will be destroyed once it
is no longer in use. Similarly, if you change a signal's combiner with
- signal::set_combiner
+ signal::set_combiner
while a signal invocation is running concurrently, the concurrent
signal invocation will continue to use the old combiner undisturbed,
while future signal invocations will receive a handle to the new combiner.
@@ -163,7 +164,7 @@
-Connections and other classes
+
Connections and other classes
The methods of the signals2::connection
class are thread-safe,
with the exception of assignment and swap. This is achived via locking the mutex
diff --git a/doc/html/signals2/tutorial.html b/doc/html/signals2/tutorial.html
index 6824d15897..e3dfe8f4a8 100644
--- a/doc/html/signals2/tutorial.html
+++ b/doc/html/signals2/tutorial.html
@@ -1,3 +1,4 @@
+
@@ -26,19 +27,19 @@
-How to Read this Tutorial
+
How to Read this Tutorial
This tutorial is not meant to be read linearly. Its top-level
structure roughly separates different concepts in the library
(e.g., handling calling multiple slots, passing values to and from
@@ -58,7 +59,7 @@ will not need to read the Advanced sectio
-Hello, World! (Beginner)
+
Hello, World! (Beginner)
The following example writes "Hello, World!" using signals and
slots. First, we create a signal sig
, a signal that
takes no arguments and has a void return value. Next, we connect
@@ -88,14 +89,14 @@ World!".
-Connecting Multiple Slots (Beginner)
+
Connecting Multiple Slots (Beginner)
Calling a single slot from a signal isn't very interesting, so
we can make the Hello, World program more interesting by splitting
the work of printing "Hello, World!" into two completely separate
@@ -139,7 +140,7 @@ Hello, World!
-Ordering Slot Call Groups (Intermediate)
+
Ordering Slot Call Groups (Intermediate)
Slots are free to have side effects, and that can mean that some
slots will have to be called before others even if they are not connected in that order. The Boost.Signals2
library allows slots to be placed into groups that are ordered in
@@ -165,7 +166,7 @@ group parameter and those that don't? The "unnamed" slots (i.e., those
that have been connected without specifying a group name) can be
placed at the front or back of the slot list (by passing
boost::signals2::at_front
or boost::signals2::at_back
-as the last parameter to connect
, respectively),
+as the last parameter to connect
, respectively),
and default to the end of the list. When
a group is specified, the final at_front
or at_back
parameter describes where the slot
@@ -203,14 +204,14 @@ Hello, World!
-Passing Values to and from Slots
+
Passing Values to and from Slots
-Slot Arguments (Beginner)
+
Slot Arguments (Beginner)
Signals can propagate arguments to each of the slots they call.
For instance, a signal that propagates mouse motion events might
want to pass along the new mouse coordinates and whether the mouse
@@ -271,7 +272,7 @@ connected to sig
must therefore be able to t
-Signal Return Values (Advanced)
+
Signal Return Values (Advanced)
Just as slots can receive arguments, they can also return
values. These values can then be returned back to the caller of the
signal through a combiner. The combiner is a mechanism
@@ -450,20 +451,20 @@ struct DistributeRequest {
-Disconnecting Slots (Beginner)
+
Disconnecting Slots (Beginner)
Slots aren't expected to exist indefinitely after they are
connected. Often slots are only used to receive a few events and
are then disconnected, and the programmer needs control to decide
@@ -472,8 +473,8 @@ when a slot should no longer be connected.
boost::signals2::connection
class. The
connection
class uniquely represents the connection
between a particular signal and a particular slot. The
-connected()
method checks if the signal and slot are
-still connected, and the disconnect()
method
+connected()
method checks if the signal and slot are
+still connected, and the disconnect()
method
disconnects the signal and slot if they are connected before it is
called. Each call to the signal's connect()
method
returns a connection object, which can be used to determine if the
@@ -489,7 +490,7 @@ connection still exists or to disconnect the signal and slot.
-Blocking Slots (Beginner)
+
Blocking Slots (Beginner)
Slots can be temporarily "blocked", meaning that they will be
ignored when the signal is invoked but have not been permanently disconnected.
This is typically used to prevent infinite recursion in cases where
@@ -498,7 +499,7 @@ invoked again. A
boost::signals2::shared_connection_block
object will
temporarily block a slot. The connection is unblocked by either
destroying or calling
-unblock
+unblock
on all the
shared_connection_block
objects that reference the connection.
Here is an example of
@@ -518,7 +519,7 @@ blocking/unblocking slots:
-Scoped Connections (Intermediate)
+
Scoped Connections (Intermediate)
The boost::signals2::scoped_connection
class
references a signal/slot connection that will be disconnected when
the scoped_connection
class goes out of scope. This
@@ -539,22 +540,22 @@ e.g.,
// doesn't compile due to compiler attempting to copy a temporary scoped_connection object
-// boost::signals2::scoped_connection c0 = sig.connect
(ShortLived());
+// boost::signals2::scoped_connection c0 = sig.connect
(ShortLived());
// okay
-boost::signals2::scoped_connection c1(sig.connect
(ShortLived()));
+boost::signals2::scoped_connection c1(sig.connect
(ShortLived()));
// also okay
boost::signals2::scoped_connection c2;
-c2 = sig.connect
(ShortLived());
+c2 = sig.connect
(ShortLived());
-Disconnecting Equivalent Slots (Intermediate)
+
Disconnecting Equivalent Slots (Intermediate)
One can disconnect slots that are equivalent to a given function
object using a form of the
-signal::disconnect
method, so long as
+signal::disconnect
method, so long as
the type of the function object has an accessible ==
operator. For instance:
@@ -609,7 +610,7 @@ public:
// ...
NewsMessageArea *newsMessageArea = new NewsMessageArea(/* ... */);
// ...
-deliverNews.connect
(boost::bind(&NewsMessageArea::displayNews,
+deliverNews.connect
(boost::bind(&NewsMessageArea::displayNews,
newsMessageArea, _1));
However, what if the user closes the news message area,
@@ -617,21 +618,21 @@ destroying the newsMessageArea
object that
deliverNews
knows about? Most likely, a segmentation
fault will occur. However, with Boost.Signals2 one may track any object
which is managed by a shared_ptr, by using
-slot::track
. A slot will automatically
+slot::track
. A slot will automatically
disconnect when any of its tracked objects expire. In
addition, Boost.Signals2 will ensure that no tracked object expires
while the slot it is associated with is in mid-execution. It does so by creating
temporary shared_ptr copies of the slot's tracked objects before executing it.
To track NewsMessageArea
, we use a shared_ptr to manage
its lifetime, and pass the shared_ptr to the slot via its
-slot::track
+slot::track
method before connecting it,
e.g.:
// ...
boost::shared_ptr<NewsMessageArea> newsMessageArea(new NewsMessageArea(/* ... */));
// ...
-deliverNews.connect
(signal_type::slot_type(&NewsMessageArea::displayNews,
+deliverNews.connect
(signal_type::slot_type(&NewsMessageArea::displayNews,
newsMessageArea.get(), _1).track(newsMessageArea));
@@ -646,14 +647,14 @@ deliverNews.newsMessageArea
itself, a copy of the shared_ptr
would
have been bound into the slot function, preventing the shared_ptr
from expiring. However, the use of
- slot::track
+ slot::track
implies we wish to allow the tracked object to expire, and automatically
disconnect the connection when this occurs.
shared_ptr
classes other than boost::shared_ptr
(such as std::shared_ptr
) may also be tracked for connection management
- purposes. They are supported by the slot::track_foreign
method.
+ purposes. They are supported by the slot::track_foreign
method.
Signal/slot disconnections occur when any of these conditions
occur:
@@ -730,7 +731,7 @@ signal.
-Passing Slots (Intermediate)
+
Passing Slots (Intermediate)
Slots in the Boost.Signals2 library are created from arbitrary
function objects, and therefore have no fixed type. However, it is
commonplace to require that slots be passed through interfaces that
@@ -919,7 +920,7 @@ private:
access to a signals2::connection
object which references
the invoking signal-slot connection. The difficulty is,
the connection
object is returned by the
- signal::connect
+ signal::connect
method, and therefore is not available until after the slot is
already connected to the signal. This can be particularly troublesome
in a multi-threaded environment where the signal may be invoked
@@ -927,11 +928,11 @@ private:
Therefore, the signal classes provide
- signal::connect_extended
+ signal::connect_extended
methods, which allow slots which take an extra argument to be connected to a signal.
The extra argument is a signals2::connection
object which refers
to the signal-slot connection currently invoking the slot.
- signal::connect_extended
+ signal::connect_extended
uses slots of the type given by the
signal::extended_slot_type
typedef.
@@ -940,7 +941,7 @@ private:
The examples section includes an
extended_slot
program which demonstrates the syntax for using
- signal::connect_extended
.
+ signal::connect_extended
.
@@ -979,7 +980,7 @@ bs2::signal_type<void (int), mutex_type<bs2::dummy_mutex> >::type si
-Linking against the Signals2 library
+
Linking against the Signals2 library
Unlike the original Boost.Signals library, Boost.Signals2 is currently header-only.
--
cgit v1.2.3