Re: Do i need to lock getting EODatabaseContext's snapshotForGlobalID() ?
Re: Do i need to lock getting EODatabaseContext's snapshotForGlobalID() ?
- Subject: Re: Do i need to lock getting EODatabaseContext's snapshotForGlobalID() ?
- From: Chuck Hill <email@hidden>
- Date: Mon, 7 Jan 2008 19:59:12 -0800
Hi Peter,
On Jan 7, 2008, at 7:09 PM, Peter Vandoros wrote:
Hi List,
I need to get to the EODatabaseContext's snapshot for a particular
EOGlobalID and was wondering if i needed to do any other locking
other than on the EOEditingContext i am passing in to the method
below?
Yes, you do.
public static NSDictionar databaseContextSnapshotForGlobalID
(EOEditingContext ec, EOGlobalID globalID) {
EOObjectStoreCoordinator osc = (EOObjectStoreCoordinator)
ec.rootObjectStore();
EODatabaseContext dbc = (EODatabaseContext)
osc.objectStoreForGlobalID( globalID );
return dbc.snapshotForGlobalID( globalID );
}
I have looked at WOnder's
RXEOAccessUtilities.databaseContextForObject() method and found
that no locking is done.
But that method does not _do_ anything with the context, it only
locates and returns it. The call to a method on the OSC is a little
iffy, but probably OK without locking.
I thought that we _always_ need to lock the
EOObjectStoreCoordinator and EODatabaseContext even if we have
already locked the EOEditingContext because other
EOEditingContext's could be accessing the them at the same time on
a different Thread. Isn't this correct or is this a special
exception to the rule?
You need to lock it if you are going to call methods on it. There
are probably some safe methods, but I'd rather lock. In your code
above, you do need to lock the context around the snapshotForGlobalID
call.
Chuck
--
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