<?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>Josh Haberman &#187; wanted</title>
	<atom:link href="http://blog.reverberate.org/tag/wanted/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.reverberate.org</link>
	<description>parsing, performance, minimalism with C99</description>
	<lastBuildDate>Wed, 02 Dec 2009 20:45:36 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Wanted: a portable mutex and atomic refcount</title>
		<link>http://blog.reverberate.org/2009/08/14/wanted-a-portable-mutex-and-atomic-refcount/</link>
		<comments>http://blog.reverberate.org/2009/08/14/wanted-a-portable-mutex-and-atomic-refcount/#comments</comments>
		<pubDate>Sat, 15 Aug 2009 02:12:02 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[wanted]]></category>

		<guid isPermaLink="false">http://blog.reverberate.org/?p=275</guid>
		<description><![CDATA[upb needs to have some lightweight thread-aware behavior.  I&#8217;m leaving most synchronization up to users (individual messages will not be thread-safe), but there are a few central structures I need to make thread-safe and reference-counted.
I need only the tiniest bit of functionality:

a portable mutex.
a portable atomic_t that lets me atomic_inc() and atomic_dec().

We&#8217;re talking &#8220;lives [...]]]></description>
			<content:encoded><![CDATA[<p>upb needs to have some lightweight thread-aware behavior.  I&#8217;m leaving most synchronization up to users (individual messages will <i>not</i> be thread-safe), but there are a few central structures I need to make thread-safe and reference-counted.</p>
<p>I need only the tiniest bit of functionality:</p>
<ul>
<li>a portable mutex.</li>
<li>a portable atomic_t that lets me atomic_inc() and atomic_dec().</li>
</ul>
<p>We&#8217;re talking &#8220;lives in one single header&#8221; small.  The mutex would just be wrappers around existing mutex implementations (pthreads, windows, etc), and since those routines typically take care of any memory barriers you need to safely read/mutate the shared state, I wouldn&#8217;t have to worry about that.</p>
<p>The atomic type would have to be hand-coded and architecture-specific, since most threading libraries don&#8217;t provide one.  The reason for providing this would be reference-counting.  If you are reference-counting an immutable structure, then you don&#8217;t need to worry about memory barriers to ensure the consistency of that structure; if you&#8217;re reference-counting a <i>mutable</i> structure, then you&#8217;ll need to  protect the mutable state with mutexes and acquire the mutex before freeing anything.</p>
<p>The library (er, header file) should also support compiling everything to nothing if NO_THREAD_SAFETY is defined as a preprocessor symbol.</p>
<p>Yes, that all sounds good.  Tiny yet functional.  I&#8217;ll be writing this very soon unless something exactly like what I&#8217;ve described happens to already exist.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.reverberate.org/2009/08/14/wanted-a-portable-mutex-and-atomic-refcount/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
