[glibmm] ThreadPool::push() docs: Note that sigc::trackable is not thread-safe.



commit 52009d77cc4247ce40f0bb4caaeab69d8bb983f4
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date:   Wed Feb 20 15:42:28 2013 +0100

    ThreadPool::push() docs: Note that sigc::trackable is not thread-safe.
    
    * glib/glibmm/threadpool.h: push(): Describe how sigc::trackable-derived
    classes can be used in a thread-safe way.
    * glib/src/threads.hg: create(): Correct the description added in the
    previous commit. Bug #512348.

 ChangeLog                |    9 +++++++++
 glib/glibmm/threadpool.h |   10 ++++++++++
 glib/src/threads.hg      |    4 ++--
 3 files changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 030dcf1..1a85f96 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2013-02-20  Kjell Ahlstedt  <kjell ahlstedt bredband net>
 
+       ThreadPool::push() docs: Note that sigc::trackable is not thread-safe.
+
+       * glib/glibmm/threadpool.h: push(): Describe how sigc::trackable-derived
+       classes can be used in a thread-safe way.
+       * glib/src/threads.hg: create(): Correct the description added in the
+       previous commit. Bug #512348.
+
+2013-02-20  Kjell Ahlstedt  <kjell ahlstedt bredband net>
+
        Threads::Thread::create(): Update the documentation.
 
        * examples/thread/thread.cc: Don't derive from sigc::trackable.
diff --git a/glib/glibmm/threadpool.h b/glib/glibmm/threadpool.h
index 9cb0f2d..2c65c2e 100644
--- a/glib/glibmm/threadpool.h
+++ b/glib/glibmm/threadpool.h
@@ -62,11 +62,21 @@ public:
   explicit ThreadPool(int max_threads = -1, bool exclusive = false);
   virtual ~ThreadPool();
 
+  //See http://bugzilla.gnome.org/show_bug.cgi?id=512348 about the sigc::trackable issue.
+  // TODO: At the next ABI break, consider changing const sigc::slot<void>& slot
+  // to const std::function<void()>& func, if it can be assumed that all supported
+  // compilers understand the C++11 template class std::function<>.
   /** Inserts @a slot into the list of tasks to be executed by the pool.
    * When the number of currently running threads is lower than the maximal
    * allowed number of threads, a new thread is started (or reused).  Otherwise
    * @a slot stays in the queue until a thread in this pool finishes its
    * previous task and processes @a slot.
+   *
+   * Because sigc::trackable is not thread-safe, if the slot represents a
+   * non-static class method and is created by sigc::mem_fun(), the class concerned
+   * should not derive from sigc::trackable. You can use, say, boost::bind() or,
+   * in C++11, std::bind() or a C++11 lambda expression instead of sigc::mem_fun().
+   *
    * @param slot A new task for the thread pool.
    * @throw Glib::ThreadError An error can only occur when a new thread
    * couldn't be created. In that case @a slot is simply appended to the
diff --git a/glib/src/threads.hg b/glib/src/threads.hg
index de83e35..6c7ea03 100644
--- a/glib/src/threads.hg
+++ b/glib/src/threads.hg
@@ -83,7 +83,7 @@ public:
    * successfully, it is returned, otherwise a Threads::ThreadError exception is thrown.
    *
    * Because sigc::trackable is not thread-safe, if the slot represents a
-   * non-static class method created by sigc::mem_fun(), the class concerned
+   * non-static class method and is created by sigc::mem_fun(), the class concerned
    * should not derive from sigc::trackable. You can use, say, boost::bind() or,
    * in C++11, std::bind() or a C++11 lambda expression instead of sigc::mem_fun().
    *
@@ -104,7 +104,7 @@ public:
    * successfully, it is returned, otherwise a Threads::ThreadError exception is thrown.
    *
    * Because sigc::trackable is not thread-safe, if the slot represents a
-   * non-static class method created by sigc::mem_fun(), the class concerned
+   * non-static class method and is created by sigc::mem_fun(), the class concerned
    * should not derive from sigc::trackable. You can use, say, boost::bind() or,
    * in C++11, std::bind() or a C++11 lambda expression instead of sigc::mem_fun().
    *


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]