<?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[[Basisklasse Async.-Ausführung] Verbesserungsvorschläge?]]></title><description><![CDATA[<p>Hallo,</p>
<p>Ich habe mir eine kleine Klasse gebaut, mit deren Hilfe eine beliebige Operation asynchron ausgeführt werden kann.<br />
Dazu muss nur von der Klasse abgeleitet werden, und eine rein-virtuelle Methode überschrieben werden.</p>
<p>Nun möchte ich wissen, was ihr davon haltet, ob sie Threadsafe ist usw. usw.</p>
<p>Ich weiß, dass das ganze nicht allzu toll ist, es ist auch mein erster Versuch mit Multithreading, trotzdem hoffe ich, dass dies halbwegs &quot;sicher&quot; ist^^</p>
<p>Hier die Klasse:</p>
<pre><code class="language-cpp">class async_executor
{
	public:
		async_executor()
		: m_is_ready(false)
		{
		}

		bool is_ready()
		{
			boost::mutex::scoped_lock lock(m_mutex);

			return m_is_ready;
		}

		void start_async_operation()
		{
			boost::thread t(boost::bind(&amp;async_executor::start_operation_thread, this));
		}

	protected:
		virtual void thread_func() = 0;

		void set_ready()
		{
			boost::mutex::scoped_lock lock(m_mutex);
			m_is_ready = true;
		}

	private:
		void start_operation_thread()
		{
			this-&gt;thread_func();
		}

	private:
		boost::mutex m_mutex;

		bool m_is_ready;
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/205693/basisklasse-async-ausführung-verbesserungsvorschläge</link><generator>RSS for Node</generator><lastBuildDate>Fri, 09 Oct 2026 04:42:46 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/205693.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 16 Feb 2008 20:55:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [Basisklasse Async.-Ausführung] Verbesserungsvorschläge? on Sat, 16 Feb 2008 20:56:01 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Ich habe mir eine kleine Klasse gebaut, mit deren Hilfe eine beliebige Operation asynchron ausgeführt werden kann.<br />
Dazu muss nur von der Klasse abgeleitet werden, und eine rein-virtuelle Methode überschrieben werden.</p>
<p>Nun möchte ich wissen, was ihr davon haltet, ob sie Threadsafe ist usw. usw.</p>
<p>Ich weiß, dass das ganze nicht allzu toll ist, es ist auch mein erster Versuch mit Multithreading, trotzdem hoffe ich, dass dies halbwegs &quot;sicher&quot; ist^^</p>
<p>Hier die Klasse:</p>
<pre><code class="language-cpp">class async_executor
{
	public:
		async_executor()
		: m_is_ready(false)
		{
		}

		bool is_ready()
		{
			boost::mutex::scoped_lock lock(m_mutex);

			return m_is_ready;
		}

		void start_async_operation()
		{
			boost::thread t(boost::bind(&amp;async_executor::start_operation_thread, this));
		}

	protected:
		virtual void thread_func() = 0;

		void set_ready()
		{
			boost::mutex::scoped_lock lock(m_mutex);
			m_is_ready = true;
		}

	private:
		void start_operation_thread()
		{
			this-&gt;thread_func();
		}

	private:
		boost::mutex m_mutex;

		bool m_is_ready;
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1457274</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1457274</guid><dc:creator><![CDATA[The-Kenny]]></dc:creator><pubDate>Sat, 16 Feb 2008 20:56:01 GMT</pubDate></item></channel></rss>