Boost C++ Libraries: Ticket #8449: Provide swap() and/or move for signals https://svn.boost.org/trac10/ticket/8449 <p> Please, provide a member swap() function (and a free swap() overload) for signals. Moving support would also be helpful. </p> <p> Swapping can be useful to solve deadlock problems in user's code. Consider the following example: </p> <ol><li>We have an object a1 of class A, which contains a signal and a mutex for protecting A's internal state. </li><li>We have a number of objects b1 - bN of types B1 - BN which subscribe for the signal in A. </li><li>The signal in a1 is a one-time notification (i.e. it and the a1 object itself will be destroyed soon after the notification). When it is invoked, the mutex has to be locked to protect the signal from being modified. </li><li>The b1 - bN objects may need to call back methods of a1 while being notified. These methods may need to lock the mutex in a1 but this would lead to a deadlock. </li></ol><p> A typical solution for this problem is to move the signal to stack while holding the mutex, then release the mutex and invoke the signal. But this is not possible because signals do not allow swapping or moving. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8449 Trac 1.4.3 fmh6jj@… Tue, 16 Apr 2013 14:29:34 GMT <link>https://svn.boost.org/trac10/ticket/8449#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8449#comment:1</guid> <description> <p> Adding swap and move is fine by me. I'll try to do this soonish. If you are impatient, and can brave all the preprocessor macros in signal_template.hpp, then sending a patch would also be fine. I believe implementing swap should be relatively trivial, since the signal classes are pimpls with only one data member: a shared_ptr to an implementation class. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Frank Mori Hess</dc:creator> <pubDate>Mon, 22 Apr 2013 03:22:10 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/8449#comment:2 https://svn.boost.org/trac10/ticket/8449#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/84006" title="Added swap to signal classes. Fixes #8449 ">[84006]</a>) Added swap to signal classes. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8449" title="#8449: Feature Requests: Provide swap() and/or move for signals (closed: fixed)">#8449</a> </p> Ticket