You're right Sean, I was responding quickly and I misread your
pseudocode.
The basic message seems to be that for session vars, you *probably*
don't have to do a lot of locking because it takes very specific
criteria (frames or RIA, generally) for the user to execute simultaneous
separate threads.
As always, the application scope is where you need to be much more
careful because it is far more likely that multiple users could initiate
simultaneous requests.
Sound about right?
Thanks for your help!
> First off, that's the same logic I had except you now have
> extra code!
> The following does exactly the same:
>
> listener (pseudo-code):
> function addToCart(product) {
> if (not structKeyExists(session,"cart"))
> session.cart = createObject("component","cart");
> session.cart.addProduct(product);
> }
>
> > Don't you have to lock the single call to
> "session.cart.addProduct()"?
>
> Answer: unlikely but it depends...
>
> > It's in the session scope, and it seems to me that another thread
> > could possibly be reading or writing to this via the listener, so
> > shouldn't it be in an exclusive lock?
>
> Only if the *same* user can make multiple simultaneous
> requests. That's
> unlikely. If your site uses frames (or it's an RIA) it is
> theoretically
> possible that a user *might* be able to initiate two simultaneous
> requests that *might* cause a problem.
>
> Remember that the session scope is unique to each user.
>
> > And then shouldn't other reads of the cart (ie
> > "session.cart.getCart()") have readonly locks?
>
> Again, unlikely but it depends... If a single user can initiate
> sufficient simultaneous requests that multi-threading on their own
> session scope is possible, then you might need to be more aggressive
> about locking.
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev'
in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).
An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]