<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>al_lock_mutex() locks for both read and writes?</title>
		<link>http://www.allegro.cc/forums/view/615371</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Mon, 11 May 2015 16:46:02 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Shouldn&#39;t al_lock_mutex() allow locking separately for reading and writing?</p><p>ala
</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/al_lock_mutex"><span class="a">al_lock_mutex</span></a><span class="k2">(</span>AL_LOCK_WRITE<span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/al_lock_mutex"><span class="a">al_lock_mutex</span></a><span class="k2">(</span>AL_LOCK_READ<span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/al_lock_mutex"><span class="a">al_lock_mutex</span></a><span class="k2">(</span>AL_LOCK_BOTH<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

<a href="http://en.wikipedia.org/wiki/Readers%E2%80%93writer_lock">http://en.wikipedia.org/wiki/Readers%E2%80%93writer_lock</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Chris Katko)</author>
		<pubDate>Mon, 11 May 2015 12:20:32 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Not quite, it wouldn&#39;t be a mutex then. A mutex is to exclude other threads from access to a certain block of code, no matter if the block reads or writes.<br />What do you need a readers writers lock for specifically?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (beoran)</author>
		<pubDate>Mon, 11 May 2015 16:43:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>No, it&#39;s just a normal mutex not a read-write lock. You can easily implement a read-write lock using a mutex though. I think a read/write lock would be useful enough to add to Allegro&#39;s API, if someone does want to add it. However if you use C++ just use for example std::shared_lock/std::unique_lock.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Mon, 11 May 2015 16:46:02 +0000</pubDate>
	</item>
</rss>
