<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[[boost::thread] Lock Member einer Klasse]]></title><description><![CDATA[<p>Hallo,</p>
<p>also es geht um folgendes:<br />
Ich will einer Klasse eine Lock und eine Unlock Funktion verpassen.<br />
Ich arbeite mit boost:threads.<br />
Mein Problem:<br />
Laut Boost sollte man das nicht machen, sondern Locks nur innerhalb einer Funktion machen, weil Locks selbst nicht Thread sicher sind (-&gt; <a href="http://www.boost.org/doc/html/thread/rationale.html#thread.rationale.locks" rel="nofollow">http://www.boost.org/doc/html/thread/rationale.html#thread.rationale.locks</a>).</p>
<p>Hab ich trotzdem noch eine Chance ein Lock und Unlock Funktion zu bauen?</p>
<pre><code class="language-cpp">class CObject
{
public:
 CObject() : object_lock(object_mutex,false) {}

 Lock() {object_lock.lock();}
 Unlock() {object_lock.unlock(); }

private:
 boost::mutex object_mutex;
 boost::mutex::scoped_lock object_lock;

};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/181433/boost-thread-lock-member-einer-klasse</link><generator>RSS for Node</generator><lastBuildDate>Tue, 22 Sep 2026 08:07:21 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/181433.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 13 May 2007 18:46:23 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [boost::thread] Lock Member einer Klasse on Sun, 13 May 2007 18:46:23 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>also es geht um folgendes:<br />
Ich will einer Klasse eine Lock und eine Unlock Funktion verpassen.<br />
Ich arbeite mit boost:threads.<br />
Mein Problem:<br />
Laut Boost sollte man das nicht machen, sondern Locks nur innerhalb einer Funktion machen, weil Locks selbst nicht Thread sicher sind (-&gt; <a href="http://www.boost.org/doc/html/thread/rationale.html#thread.rationale.locks" rel="nofollow">http://www.boost.org/doc/html/thread/rationale.html#thread.rationale.locks</a>).</p>
<p>Hab ich trotzdem noch eine Chance ein Lock und Unlock Funktion zu bauen?</p>
<pre><code class="language-cpp">class CObject
{
public:
 CObject() : object_lock(object_mutex,false) {}

 Lock() {object_lock.lock();}
 Unlock() {object_lock.unlock(); }

private:
 boost::mutex object_mutex;
 boost::mutex::scoped_lock object_lock;

};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1284217</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1284217</guid><dc:creator><![CDATA[XCooperation]]></dc:creator><pubDate>Sun, 13 May 2007 18:46:23 GMT</pubDate></item><item><title><![CDATA[Reply to [boost::thread] Lock Member einer Klasse on Mon, 14 May 2007 06:22:05 GMT]]></title><description><![CDATA[<p>Dieser Thread wurde von Moderator/in <a href="http://www.c-plusplus.net/forum/profile-var-mode-is-viewprofile-and-u-is-18363.html" rel="nofollow">Jochen Kalmbach</a> aus dem Forum <a href="http://www.c-plusplus.net/forum/viewforum-var-f-is-4.html" rel="nofollow">WinAPI</a> in das Forum <a href="http://www.c-plusplus.net/forum/viewforum-var-f-is-15.html" rel="nofollow">C++</a> verschoben.</p>
<p>Im Zweifelsfall bitte auch folgende Hinweise beachten:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-39405.html" rel="nofollow">C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?</a></p>
<p><em>Dieses Posting wurde automatisch erzeugt.</em></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1284374</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1284374</guid><dc:creator><![CDATA[C++ Forumbot]]></dc:creator><pubDate>Mon, 14 May 2007 06:22:05 GMT</pubDate></item><item><title><![CDATA[Reply to [boost::thread] Lock Member einer Klasse on Mon, 14 May 2007 07:05:28 GMT]]></title><description><![CDATA[<p>Hm, ein Scoped Lock wäre sicherer.<br />
Ansonsten müsstest du das natürlich implementieren können.<br />
Für was brauchst du das denn?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1284390</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1284390</guid><dc:creator><![CDATA[phlox81]]></dc:creator><pubDate>Mon, 14 May 2007 07:05:28 GMT</pubDate></item><item><title><![CDATA[Reply to [boost::thread] Lock Member einer Klasse on Mon, 14 May 2007 19:05:29 GMT]]></title><description><![CDATA[<blockquote>
<p>Hab ich trotzdem noch eine Chance ein Lock und Unlock Funktion zu bauen?</p>
</blockquote>
<p>Mit boost.thread nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1284901</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1284901</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Mon, 14 May 2007 19:05:29 GMT</pubDate></item></channel></rss>