Hi,

The second idea (B) is not a good idea because you are still accessing the
SESSION scope in the CFLOOP, so you need to CFLOCK it.  Both A & C would
work fine, except in C, you need to use StructCopy, not Duplicate.  And in
all three, you spelled "attributes" as "attrubites", but other than that, A
& C are fine.
I put A & C in two different CFLOOPs that went 500 times each, and outputted
how long it took, and they both were always within 20ms of each other, so
use whichever way you want, they are equally fast.

-Brent

-----Original Message-----
From: Justin Hansen [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, August 15, 2001 8:03 AM
To: CF-Talk
Subject: locking a loop or the contents


Which code is better and why?

A: Locking the whole loop...

<cflock type="EXCLUSIVE" scope="SESSION" timeout="10">
        <cfloop collection="#evaluate("session.#attrubites.StructName#")#"
item="locField">
                <cfset "form.#locField#" =
evaluate("session.#attrubites.StructName#.#locField#")>
        </cfloop>
</cflock>


--- or ---

B: Locking the contents in the loop....

<cfloop collection="#evaluate("session.#attrubites.StructName#")#"
item="locField">
        <cflock type="EXCLUSIVE" scope="SESSION" timeout="10">
                <cfset "form.#locField#" =
evaluate("session.#attrubites.StructName#.#locField#")>
        </cflock>
</cfloop>


--- better yet ---

C: This just occured to me while asking this question....

<cflock type="EXCLUSIVE" scope="SESSION" timeout="10">
        <cfset locStruct=Duplicate("session.#attrubites.StructName#")>
</cflock>

<cfloop collection="#locStruct#" item="locField">
        <cfset "form.#locField#" = evaluate("locStruct.#locField#")>
</cfloop>


What do the masses have to say about this one?


Justin Hansen - [EMAIL PROTECTED]
Web Application Developer
Interactive Business Solutions, Inc
816-221-5200 ext. 1305
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to