<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: How to notify event listeners in MySQL</title>
	<atom:link href="http://www.xaprb.com/blog/2007/08/29/how-to-notify-event-listeners-in-mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.xaprb.com/blog/2007/08/29/how-to-notify-event-listeners-in-mysql/</link>
	<description>Stay curious!</description>
	<lastBuildDate>Thu, 09 Feb 2012 09:56:43 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Xaprb</title>
		<link>http://www.xaprb.com/blog/2007/08/29/how-to-notify-event-listeners-in-mysql/#comment-19588</link>
		<dc:creator>Xaprb</dc:creator>
		<pubDate>Sun, 21 Aug 2011 14:30:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/2007/08/29/how-to-notify-event-listeners-in-mysql/#comment-19588</guid>
		<description>Thang, it&#039;s definitely not an elegant solution, it&#039;s a kludge at best.  I wish MySQL had PostgreSQL&#039;s feature set for these purposes.

These days I wouldn&#039;t build this in the database.  I&#039;d build it with an external queueing system, or with Gearman.</description>
		<content:encoded><![CDATA[<p>Thang, it&#8217;s definitely not an elegant solution, it&#8217;s a kludge at best.  I wish MySQL had PostgreSQL&#8217;s feature set for these purposes.</p>
<p>These days I wouldn&#8217;t build this in the database.  I&#8217;d build it with an external queueing system, or with Gearman.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thang</title>
		<link>http://www.xaprb.com/blog/2007/08/29/how-to-notify-event-listeners-in-mysql/#comment-19585</link>
		<dc:creator>Thang</dc:creator>
		<pubDate>Sat, 20 Aug 2011 22:43:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/2007/08/29/how-to-notify-event-listeners-in-mysql/#comment-19585</guid>
		<description>sorry, you are right. there is an exact use if you want to lock a lock, then wait for awhile and have another thread wait.

the problem is that this exact use is limited for the reasons you mentioned.  and all the issues that come with the produce consumer problem (coke machine - www.cs.illinois.edu/class/sp11/cs423/lectures/11-reader-writer-2x3.pdf, spinning, etc. are not solved).

to develop this lock into a real produce-consumer solution, you would need to use the lock to build a condition.  finally, use the condition to signal arrival of items.  even if you manage to do this, you would have a problem of spuriously waking up consumers (for one producer-multiple consumer).  the list of short-coming continues on and on...

one practical use case is this, i want to wait for new items in a table.  i don&#039;t want to spin and i don&#039;t want to block if there are new items.  these are the 2 primary requirements for produce-consumer solution.

for example, a new select statement:

&quot;select * from mytable where id&gt;10 [but don&#039;t return until the result set is unempty];&quot;

how would you go about doing this with a lock?</description>
		<content:encoded><![CDATA[<p>sorry, you are right. there is an exact use if you want to lock a lock, then wait for awhile and have another thread wait.</p>
<p>the problem is that this exact use is limited for the reasons you mentioned.  and all the issues that come with the produce consumer problem (coke machine &#8211; <a href="http://www.cs.illinois.edu/class/sp11/cs423/lectures/11-reader-writer-2x3.pdf" rel="nofollow">http://www.cs.illinois.edu/class/sp11/cs423/lectures/11-reader-writer-2&#215;3.pdf</a>, spinning, etc. are not solved).</p>
<p>to develop this lock into a real produce-consumer solution, you would need to use the lock to build a condition.  finally, use the condition to signal arrival of items.  even if you manage to do this, you would have a problem of spuriously waking up consumers (for one producer-multiple consumer).  the list of short-coming continues on and on&#8230;</p>
<p>one practical use case is this, i want to wait for new items in a table.  i don&#8217;t want to spin and i don&#8217;t want to block if there are new items.  these are the 2 primary requirements for produce-consumer solution.</p>
<p>for example, a new select statement:</p>
<p>&#8220;select * from mytable where id&gt;10 [but don't return until the result set is unempty];&#8221;</p>
<p>how would you go about doing this with a lock?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thang</title>
		<link>http://www.xaprb.com/blog/2007/08/29/how-to-notify-event-listeners-in-mysql/#comment-19584</link>
		<dc:creator>Thang</dc:creator>
		<pubDate>Sat, 20 Aug 2011 22:25:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/2007/08/29/how-to-notify-event-listeners-in-mysql/#comment-19584</guid>
		<description>The locks used as in the code sample you have isn&#039;t signaling anything.  The threads don&#039;t wake up when an item arrives, and they still spin.  It defeats the whole purpose. 

What happens if you remove the lock and release code?  The behavior is exactly the same.  Your code would run a little faster and waste fewer CPU cycles.</description>
		<content:encoded><![CDATA[<p>The locks used as in the code sample you have isn&#8217;t signaling anything.  The threads don&#8217;t wake up when an item arrives, and they still spin.  It defeats the whole purpose. </p>
<p>What happens if you remove the lock and release code?  The behavior is exactly the same.  Your code would run a little faster and waste fewer CPU cycles.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Xaprb</title>
		<link>http://www.xaprb.com/blog/2007/08/29/how-to-notify-event-listeners-in-mysql/#comment-19583</link>
		<dc:creator>Xaprb</dc:creator>
		<pubDate>Sat, 20 Aug 2011 21:28:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/2007/08/29/how-to-notify-event-listeners-in-mysql/#comment-19583</guid>
		<description>You&#039;re missing the point.  The lock isn&#039;t about atomicity, it&#039;s about signaling.</description>
		<content:encoded><![CDATA[<p>You&#8217;re missing the point.  The lock isn&#8217;t about atomicity, it&#8217;s about signaling.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thang</title>
		<link>http://www.xaprb.com/blog/2007/08/29/how-to-notify-event-listeners-in-mysql/#comment-19579</link>
		<dc:creator>Thang</dc:creator>
		<pubDate>Sat, 20 Aug 2011 13:08:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/2007/08/29/how-to-notify-event-listeners-in-mysql/#comment-19579</guid>
		<description>The lock as used in the post is useless.  SELECT and INSERT commands are naturally atomic.  There is absolutely no need for locks if one wants to select and insert in such a manner.  The lock and release code can be removed without any adverse effect.</description>
		<content:encoded><![CDATA[<p>The lock as used in the post is useless.  SELECT and INSERT commands are naturally atomic.  There is absolutely no need for locks if one wants to select and insert in such a manner.  The lock and release code can be removed without any adverse effect.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

