Andrew, I just don't see what your code example has to do with race
conditions.  <cfset> is an atomic operation (didn't used to be, but that's
been fixed) so no race condition is possible.  Using locks like this is a
bizarre but mostly harmless practice that is only common in ColdFusion
because of bugs in earlier versions.  What *isn't* harmless is the notion
that doing this in any way protects you from a real race condition.

I'm preaching to the choir here, but for the record, a race condition looks
like this:

1. I query some piece of shared state.
2. Some other thread or process changes that state
3. I perform some operation that depends on the state not having changed.

Even if we restrict the problem to, say, just the CF session scope, the only
blanket approach that will prevent race conditions is to single-thread the
whole session.  Locking single <cfset> tags in setter functions will do
nothing for you.

If you don't want to single thread the session (and if you're doing frames
or AJAX you shouldn't), you need to understand for every operation what
shared state it depends on and what the impact of a change in the shared
state would be.   If there would be an impact you care about, put the
querying of the state and the operation where you use it as close together
as possible and wrap them in a lock.

Jaime Metcher

> -----Original Message-----
> From: Andrew Scott [mailto:[EMAIL PROTECTED]
> Sent: Saturday, 14 April 2007 1:04 PM
> To: CF-Talk
> Subject: Re: Using CFCs in session scope - need cflock help
>
>
> Jason,
>
> I answered your question, in my post I gave you a code example of what you
> need to do.
>
> So the answer is yes, when writing to any scoped variable you must cflock
> the write. I am very sure I said that:-)
>
>



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
ColdFusion MX7 and Flex 2 
Build sales & marketing dashboard RIA’s for your business. Upgrade now
http://www.adobe.com/products/coldfusion/flex2?sdid=RVJT

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:275220
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to