This usage of var is _not_ helping with thread safety because you're only
using it to avoid having to qualify your with the variables scope. Var only
helps with thread safety when it is the original instantiation of the
variable - all you are doing is referencing an existing shared object. Your
code is functionally equivalent to skipping the var statement entirely and
just writing the follwing:
<cfset variables.transferBean = createobject("component","transferBean")>
<cffunction name="someProcess" returntype="transferBean">
<cfset variables.transfer.setValue(result from something)>
<cfreturn variables.transfer>
</cffunction>
This is not thread safe. If two threads call someProcess at the same time,
there is the potential for transfer.setValue to be called twice before the
cfreturn statements get executed.
Roland
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Kevin J. Miller
Sent: Friday, September 24, 2004 10:33 AM
To: [EMAIL PROTECTED]
Subject: RE: [CFCDev] Testing Thread Safety
What do you see is the danger there, that an update to the local transfer
variable would update the variables.transferBean original object? I don't
see how that's possible, given that it has been scoped locally (regardless
of passing by reference). Ultimately, this is the precise issue I'm trying
to clarify. But what you're saying is that *this* usage of local scoped
vars is NOT thread safe? Can that be true?
Kevin
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of David Ross
> Sent: Friday, September 24, 2004 4:12 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [CFCDev] Testing Thread Safety
>
>
> I'd say that's NOT thread safe, as the local var is only a
> pointer to the variables instance. Two simultaneous requests
> will both have separate variables, but since they're both
> pointing at the same thing, it won't make a difference. You
> need to instantiate your transfer bean component into the
> local var "scope".
>
> -Dave
>
> >>> [EMAIL PROTECTED] 9/24/2004 7:16:09 AM >>>
>
> >
> > I am not "positive"... but doesn't a object (like a CFC) get
> > passed by ref? Does it recreate transferBean in var scope as
> > transfer... or does transfer just get assigned the reference
> > of the object... allowing both variables to address the same object?
>
> This is exactly the question. I can and will test it of
> course, but I was wondering if it was a known behavior one
> way or the other. With all the hooha about local scoping
> vars in functions, I would presume that doing the <cfset var
> transfer = variables.transferBean> WOULD be ok. Thought the
> braintrust would have an answer on this.
>
> Kevin
> ----------------------------------------------------------
> 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]
>
----------------------------------------------------------
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]
----------------------------------------------------------
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]