> No, it says you have to think about whether you need to lock or not,
> just like in other languages. Consider this construct:

>       <cfif isDefined("server.myVar")>
>               <cfset server.myVar = createObject("component","foo")/>
>               <cfset server.init()/>
>       </cfif>

> If this can be executed by multiple requests simultaneously, you need
> to lock it. Where do you need the lock? Just around the update? No, in
> this case you need the lock around the whole <cfif.../> tag. Why?
> Consider this (bogus) code:

>       <cfif isDefined("server.myVar")>
>               <cflock name="server_myVar" type="exclusive">
>                       <cfset server.myVar = createObject("component","foo")/>
>                       <cfset server.myVar.init()/>
>               </cflock>
>       </cfif>

I'm curious. Can anyone explain to me why createObject() isn't enough to
instantiate the object? I mean, why it is that <cfset server.myVar.init()/>
would even be required here? It seems to me like the init() could just as
well be an assumed part of a constructor for the object/cfc/etc... And
better still because it would be less code and less prone to screw-ups that
way.

S. Isaac Dealey
Certified Advanced ColdFusion 5 Developer

www.turnkey.to
954-776-0046
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm

Reply via email to