Re: Enumerating EOs in a new thread
Re: Enumerating EOs in a new thread
- Subject: Re: Enumerating EOs in a new thread
- From: Chuck Hill <email@hidden>
- Date: Fri, 25 Jan 2008 10:10:48 -0800
On Jan 25, 2008, at 9:29 AM, Guido Neitzer wrote:
On 25.01.2008, at 04:27, Paul Stringer wrote:
I've encountered this before when working with EO's in separate
threads, are there some rules to follow when doing so?
Yes, there are. Don't pass EOs between threads. ;-)
There are a couple of things to keep in mind:
- EOF will be blocked by your background thread as long as it's
running and not using its own object store coordinator.
I don't think that is exactly correct. EOF is only blocked during a
fetch or a save. Unless the thread is doing a lot of fetches or
making long saves (lots of EOs), EOF locking should not be a problem.
There is a common and similar problem. If the thread uses and locks
an EC that is also locked by the session, the user's session will be
blocked until the thread exits. Is that what you were thinking of?
Chuck
- To pass enterprise objects over to a different object store
coordinator, you have to refault them.
- You still might do things in the wrong order and therefor perhaps
locking the wrong editing context or so.
My advice: pass an array of global ids or primary keys to the
thread, build the array of enterprise objects there inside a
separate editing context on a separate object store coordinator.
Then you get your own connection to the database and you're not
blocking the rest.
If you are using Wonder: there are two methods in
ERXEOControlUtilities for getting an array of global ids from an
array of eos and vice versa.
Remember to close your database connection when you're done, and to
lock / unlock everything properly.
cug
--
Real-World WebObjects class at the Big Nerd Ranch
March 2008, Frankfurt, Germany
http://www.bignerdranch.com/classes/webobjects.shtml
--
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden