[gtkmm-documentation] Amend the "Multi-threaded programs" chapter.
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm-documentation] Amend the "Multi-threaded programs" chapter.
- Date: Wed, 20 Feb 2013 07:53:23 +0000 (UTC)
commit 01ad21498c725aba6a04c58d963a3c3a5460dfef
Author: Chris Vine <chris cvine freeserve co uk>
Date: Tue Feb 19 18:42:20 2013 +0100
Amend the "Multi-threaded programs" chapter.
* docs/tutorial/C/gtkmm-tutorial-in.xml: Cover the use of std::bind(),
boost::bind() and C++11 lambda expressions to safely call
Glib::Threads::Thread::create(). Bug #512348.
ChangeLog | 8 +++++
docs/tutorial/C/gtkmm-tutorial-in.xml | 46 +++++++++++++++++---------------
2 files changed, 32 insertions(+), 22 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 14d5148..ee932b7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2013-02-19 Chris Vine <chris cvine freeserve co uk>
+
+ Amend the "Multi-threaded programs" chapter.
+
+ * docs/tutorial/C/gtkmm-tutorial-in.xml: Cover the use of std::bind(),
+ boost::bind() and C++11 lambda expressions to safely call
+ Glib::Threads::Thread::create(). Bug #512348.
+
2013-02-17 Chris Vine <chris cvine freeserve co uk>
Add "Multi-threaded programs" chapter.
diff --git a/docs/tutorial/C/gtkmm-tutorial-in.xml b/docs/tutorial/C/gtkmm-tutorial-in.xml
index befc328..ec45a9d 100644
--- a/docs/tutorial/C/gtkmm-tutorial-in.xml
+++ b/docs/tutorial/C/gtkmm-tutorial-in.xml
@@ -7235,9 +7235,10 @@ mutex or other means of synchronization.
These interactions arise from the fact that, amongst other things, a
class inheriting from <classname>sigc::trackable</classname> will, via
that inheritance, have a <classname>std::list</classname> object
-keeping track of slots representing any of its non-static methods
-(more particularly it keeps a list of callbacks which will null the
-connected slots on its destruction). Each
+keeping track of slots created by calls to
+<function>sigc::mem_fun()</function> representing any of its
+non-static methods (more particularly it keeps a list of callbacks
+which will null the connected slots on its destruction). Each
<classname>sigc::slot</classname> object also keeps, via
<classname>sigc::slot_rep</classname>, its own
<classname>sigc::trackable</classname> object to track any
@@ -7264,12 +7265,6 @@ from <classname>sigc::trackable</classname>, because the effects are
unintuitive (see particularly points 4 and 5 below).
</para>
-<para>
-The rules for non-static methods apply also for static methods, if
-<function>sigc::mem_fun()</function> is used. It is better to use
-<function>sigc::ptr_fun()</function> for static methods.
-</para>
-
<orderedlist>
<listitem>
@@ -7308,14 +7303,19 @@ the object.
<listitem>
<para>
-A <classname>sigc::slot</classname> object which references a
-non-static method of a class deriving from
-<classname>sigc::trackable</classname> should never be copied to
-another thread, nor destroyed by a different thread than the one which
-created it (one consequence of this is that
-<methodname>Glib::Threads::Thread::create()</methodname> should not be called
-with a slot argument which represents a non-static method of such a
-class).
+A <classname>sigc::slot</classname> object created by a call to
+<function>sigc::mem_fun()</function> which references a method of a
+class deriving from <classname>sigc::trackable</classname> should
+never be copied to another thread, nor destroyed by a different thread
+than the one which created it. (One consequence of this is that
+<methodname>Glib::Threads::Thread::create()</methodname> should not be
+called with a slot argument created by a call to
+<function>sigc::mem_fun()</function> which represents a method of such
+a class. It is however safe to pass
+<methodname>Glib::Threads::Thread::create()</methodname> a function
+object representing such a method by using, say,
+<function>boost::bind()</function> or, in C++11,
+<function>std::bind()</function> or a C++11 lambda expression.)
</para>
</listitem>
@@ -7324,12 +7324,12 @@ class).
If a particular class object derives from
<classname>sigc::trackable</classname>, only one thread should create
<classname>sigc::slot</classname> objects representing any of the
-class's non-static methods, that is, create slots with
+class's non-static methods by calling
<function>sigc::mem_fun()</function>. The first thread to create such
a slot should be regarded as owning the relevant object for the
purpose of creating further slots referencing <emphasis>any</emphasis>
-of its non-static methods or nulling those slots by disconnecting them
-or destroying the trackable object.
+of its non-static methods using that function, or nulling those slots
+by disconnecting them or destroying the trackable object.
</para>
</listitem>
@@ -7351,8 +7351,10 @@ The connect*_once() variants,
<methodname>Glib::SignalIdle::connect_once()</methodname>,
<methodname>Glib::SignalTimeout::connect_once()</methodname>,
<methodname>Glib::SignalTimeout::connect_seconds_once()</methodname>,
-are thread-safe for any case where the slot does not relate to a non-static
-method of a class deriving from <classname>sigc::trackable</classname>.
+are thread-safe for any case where the slot is not created by a call to
+<function>sigc::mem_fun()</function> which represents a method of a class
+deriving from <classname>sigc::trackable</classname>. This is similar to
+<methodname>Glib::Threads::Thread::create()</methodname> as mentioned in point 4.
</para>
</listitem>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]