Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question
0

references to objects in space within the same pu

I have a general question. Lets say I have one pu and two threads that can reference the same object in the space independently. If the first thread has read the object in the space and the second thread updates that same object, does the reference see the update or am I required to re-read the object again from the space to get the update.

My issue is the first thread is a synchronous operation that is manipulating the object where the second thread might update that same object due to some autonomous event. I am worried about a possible race condition that can happen on the same object within same pu on two different threads.

Thanks

Rich

{quote}This thread was imported from the previous forum. For your reference, the original is [available here|http://forum.openspaces.org/thread.jspa?threadID=3794]{quote}

asked 2011-11-29 14:48:00 -0500

rchristy gravatar image

updated 2013-08-08 09:52:00 -0500

jaissefsfex gravatar image
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

Rich,
To avoid race conditions you should read using exclusive read lock.
In embedded mode , you are getting back a shallow copy when reading an object from the space.
This means you are getting a reference into non-primitive fields and a copy for a primitive field. , so you have to re-read the object before you update it. This will make sure also indexes will be updated.
Shay

answered 2011-11-29 15:49:42 -0500

shay hassidim gravatar image
edit flag offensive delete link more
0

Thanks Shay, I ended up splitting my object model up a bit to avoid the race condition.

answered 2011-12-07 09:42:19 -0500

rchristy gravatar image
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2011-11-29 14:48:00 -0500

Seen: 79 times

Last updated: Dec 07 '11