<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Visual C++ Tips &#187; InterlockedDecrement</title>
	<atom:link href="http://weseetips.com/tag/interlockeddecrement/feed/" rel="self" type="application/rss+xml" />
	<link>http://weseetips.com</link>
	<description>Gold mine of Visual C++ tricks!</description>
	<lastBuildDate>Thu, 11 Mar 2010 09:09:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Interlocked family of functions for simple Synchronizations.</title>
		<link>http://weseetips.com/2008/03/24/interlocked-family-of-functions-for-simple-synchronizations/</link>
		<comments>http://weseetips.com/2008/03/24/interlocked-family-of-functions-for-simple-synchronizations/#comments</comments>
		<pubDate>Mon, 24 Mar 2008 19:00:44 +0000</pubDate>
		<dc:creator>Jijo Raj</dc:creator>
				<category><![CDATA[Codeproject]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[InterlockedCompareExchange]]></category>
		<category><![CDATA[InterlockedDecrement]]></category>
		<category><![CDATA[InterlockedExchange]]></category>
		<category><![CDATA[InterlockedExchangePointer]]></category>
		<category><![CDATA[InterlockedIncrement]]></category>
		<category><![CDATA[multithreading]]></category>
		<category><![CDATA[synchornization]]></category>
		<category><![CDATA[VC++]]></category>
		<category><![CDATA[Visual C++]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://weseetips.wordpress.com/?p=28</guid>
		<description><![CDATA[In multithreaded environment we usually use Mutex to synchronize access to resources. But sometimes our resources may be a single integer member variable which holds some count or like that. For such light weight resource, using mutex is not preferred. For that you can Interlocked family of functions. Please see some of the functions below. [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://weseetips.wordpress.com/files/2008/03/icon_description.jpg" alt="Icon Description" /><br />
In multithreaded environment we usually use Mutex to synchronize access to resources. But sometimes our resources may be a single integer member variable which holds some count or like that. For such light weight resource, using mutex is not preferred.</p>
<p><img src="http://weseetips.wordpress.com/files/2008/03/icon_howcanidoit.jpg" alt="Icon How Can I Do It?" /><br />
For that you can Interlocked family of functions. Please see some of the functions below.</p>
<pre><span style="color:#000000;">InterlockedIncrement()
InterlockedDecrement()
InterlockedExchange()
InterlockedCompareExchange()
InterlockedExchangePointer()
…</span></pre>
<p>For example if you need to increment a member variable threadsafely, you can use InterlockedIncrement(). That function will ensure the thread synchronization without any additional kernel objects such as mutex etc… Please see the code block below.</p>
<pre><span style="color:#000000;">long m_lCount = 0;
...
// Increment the value.
InterlockedIncrement( &amp;m_lCount );</span></pre>
<p>InterlockedExchangePointer()</p>
]]></content:encoded>
			<wfw:commentRss>http://weseetips.com/2008/03/24/interlocked-family-of-functions-for-simple-synchronizations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

