<?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"
	>
<channel>
	<title>Comments on: Core Data and Multi-threading</title>
	<atom:link href="http://www.losingfight.com/blog/2006/10/14/core-data-and-multi-threading/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.losingfight.com/blog/2006/10/14/core-data-and-multi-threading/</link>
	<description>objective-c and c++ code for the mac</description>
	<pubDate>Fri, 05 Dec 2008 09:07:45 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
		<item>
		<title>By: Scott Stevenson</title>
		<link>http://www.losingfight.com/blog/2006/10/14/core-data-and-multi-threading/#comment-587</link>
		<dc:creator>Scott Stevenson</dc:creator>
		<pubDate>Fri, 20 Oct 2006 21:15:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.losingfight.com/blog/2006/10/14/core-data-and-multi-threading/#comment-587</guid>
		<description>&lt;i&gt;Core Data can make something part of the equation&lt;/i&gt;

Wow. Something got mixed up there. It should have read "can make some part of the equation easier".</description>
		<content:encoded><![CDATA[<p><i>Core Data can make something part of the equation</i></p>
<p>Wow. Something got mixed up there. It should have read &#8220;can make some part of the equation easier&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott Stevenson</title>
		<link>http://www.losingfight.com/blog/2006/10/14/core-data-and-multi-threading/#comment-586</link>
		<dc:creator>Scott Stevenson</dc:creator>
		<pubDate>Fri, 20 Oct 2006 21:14:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.losingfight.com/blog/2006/10/14/core-data-and-multi-threading/#comment-586</guid>
		<description>&lt;i&gt;Finally, Core Data is not really a good choice for an NNTP server, but you will find out&lt;/i&gt;

I don't agree with that. No matter how you slice it, Core Data can make something part of the equation. If you don't want to use its persistence engine, you can opt out of that and just use it for change tracking and UI population.

Core Data's speed can be extremely competitive with raw SQLite if used properly, which was explained at one session at WWDC.</description>
		<content:encoded><![CDATA[<p><i>Finally, Core Data is not really a good choice for an NNTP server, but you will find out</i></p>
<p>I don&#8217;t agree with that. No matter how you slice it, Core Data can make something part of the equation. If you don&#8217;t want to use its persistence engine, you can opt out of that and just use it for change tracking and UI population.</p>
<p>Core Data&#8217;s speed can be extremely competitive with raw SQLite if used properly, which was explained at one session at WWDC.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy</title>
		<link>http://www.losingfight.com/blog/2006/10/14/core-data-and-multi-threading/#comment-528</link>
		<dc:creator>Andy</dc:creator>
		<pubDate>Tue, 17 Oct 2006 01:42:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.losingfight.com/blog/2006/10/14/core-data-and-multi-threading/#comment-528</guid>
		<description>Hi Jakob,

I do know about CFSocket/NSStream and NSRunLoop, etc. The main reason for wanting to use kqueue is the same reason for wanting to use Core Data in Wombat. That is, I've never used kqueue before and wanted to learn.

I've also heard that kqueue is much more efficient/scalable that select. I'm not sure what NSRunLoop/CFRunLoop uses; it might use kqueue behind the scenes making my direct use of kqueue rather pointless.</description>
		<content:encoded><![CDATA[<p>Hi Jakob,</p>
<p>I do know about CFSocket/NSStream and NSRunLoop, etc. The main reason for wanting to use kqueue is the same reason for wanting to use Core Data in Wombat. That is, I&#8217;ve never used kqueue before and wanted to learn.</p>
<p>I&#8217;ve also heard that kqueue is much more efficient/scalable that select. I&#8217;m not sure what NSRunLoop/CFRunLoop uses; it might use kqueue behind the scenes making my direct use of kqueue rather pointless.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Hanson</title>
		<link>http://www.losingfight.com/blog/2006/10/14/core-data-and-multi-threading/#comment-518</link>
		<dc:creator>Chris Hanson</dc:creator>
		<pubDate>Mon, 16 Oct 2006 14:30:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.losingfight.com/blog/2006/10/14/core-data-and-multi-threading/#comment-518</guid>
		<description>You can use a SQLite persistent store from multiple Core Data persistence stacks (coordinators) at once, whether they're in the same or multiple processes.  As Jakob pointed out, depending on your filesystem and its locking support, this can place limits on your performance; however, on a local filesystem, SQLite should be using byte-range locking rather than simple file locking.  You should be able to see this yourself from the public SQLite source code.

You're also absolutely correct about having to lock a context any time you access or manipulate its managed objects.  As a convenience, you don't have to do this if (a) you create the context in the same thread as you use it and (b) you use it (and its object graph) only in that thread.  The practical upshot of the above is as you discovered, that you can use multiple contexts to achieve your goals.  Here's a good article explaining why all of the above is the case by Ben Trumbull; it's from the WebObjects list and covers EOEditingContext, which is the spiritual forebear of NSManagedObjectContext:  http://lists.apple.com/archives/Webobjects-dev/2004/Dec/msg00255.html</description>
		<content:encoded><![CDATA[<p>You can use a SQLite persistent store from multiple Core Data persistence stacks (coordinators) at once, whether they&#8217;re in the same or multiple processes.  As Jakob pointed out, depending on your filesystem and its locking support, this can place limits on your performance; however, on a local filesystem, SQLite should be using byte-range locking rather than simple file locking.  You should be able to see this yourself from the public SQLite source code.</p>
<p>You&#8217;re also absolutely correct about having to lock a context any time you access or manipulate its managed objects.  As a convenience, you don&#8217;t have to do this if (a) you create the context in the same thread as you use it and (b) you use it (and its object graph) only in that thread.  The practical upshot of the above is as you discovered, that you can use multiple contexts to achieve your goals.  Here&#8217;s a good article explaining why all of the above is the case by Ben Trumbull; it&#8217;s from the WebObjects list and covers EOEditingContext, which is the spiritual forebear of NSManagedObjectContext:  <a href="http://lists.apple.com/archives/Webobjects-dev/2004/Dec/msg00255.html" rel="nofollow">http://lists.apple.com/archives/Webobjects-dev/2004/Dec/msg00255.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jakob Stoklund Olesen</title>
		<link>http://www.losingfight.com/blog/2006/10/14/core-data-and-multi-threading/#comment-502</link>
		<dc:creator>Jakob Stoklund Olesen</dc:creator>
		<pubDate>Sun, 15 Oct 2006 11:08:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.losingfight.com/blog/2006/10/14/core-data-and-multi-threading/#comment-502</guid>
		<description>Andy,

SQLite does in fact allow multiple processes to edit a database at the same time, and it works too. It uses file-level locking to do this, so performance is less than stellar if you have many processes.

One thing you need to consider when doing multithreaded Core Data is that changes are not processed automatically outside the GUI thread. You need to regularly save, fetch, or call -processPendingChanges manually.

Another thing: when using multiple contexts, you need to use -refreshObject:mergeChanges: to keep contexts up to date. This is the only way of propagating changes between existing contexts.

As for multiplexing sockets, do you know about CFSocket and NSStream? kqueue is pretty low level, not that there is anything wrong with that.

Finally, Core Data is not really a good choice for an NNTP server, but you will find out :-)</description>
		<content:encoded><![CDATA[<p>Andy,</p>
<p>SQLite does in fact allow multiple processes to edit a database at the same time, and it works too. It uses file-level locking to do this, so performance is less than stellar if you have many processes.</p>
<p>One thing you need to consider when doing multithreaded Core Data is that changes are not processed automatically outside the GUI thread. You need to regularly save, fetch, or call -processPendingChanges manually.</p>
<p>Another thing: when using multiple contexts, you need to use -refreshObject:mergeChanges: to keep contexts up to date. This is the only way of propagating changes between existing contexts.</p>
<p>As for multiplexing sockets, do you know about CFSocket and NSStream? kqueue is pretty low level, not that there is anything wrong with that.</p>
<p>Finally, Core Data is not really a good choice for an NNTP server, but you will find out <img src='http://www.losingfight.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.753 seconds -->
