On Jan 3, 2008 12:24 PM, Raymond Camden <[EMAIL PROTECTED]> wrote:
> Just note though - that lock isn't really necessary if all you are
> doing is setting a bunch of simple values in the app scope. And by
> simple I mean things that dont' need to be single threaded. A CFC
> stored in the app scope is most likely fine as well.

Careful! That's not necessarily true if there are multiple variables
and the integrity of the code relies on them not being set
inconsistently. In other words, race condition *can* still apply here
depending on how atomic the initialization code is...

As for the CFC, if you have init code like this:

application.someVar = createObject("component","MyThing");
application.someVar.someMethod(42);

then that may well not be safe either - in particular if "someMethod"
is actually "init"! - because the application code may depend on
someVar being in at least the state that someMethod() puts it in (and
other requests could access application.someVar after the
createObject() but before the someMethod() call).

A safer way to do that initialization is:

var someVar = createObject("component","MyThing");
someVar.someMethod(42);
application.someVar = someVar;

i.e., fully initialize the component before placing it in application scope.
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:295800
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