> > <cfif not structKeyExists(session,"FormStateManager")>
> > <cflock name="FormStateManager" type="exclusive" timeout="10">
> > <cfif not structKeyExists(session,"FormStateManager")>
> > <cfset session.FormStateManager =
> > createObject("component", "FormStateManager") />
> > </cfif>
> > </cflock>
> > </cfif>
>
> Dan, one question about the code you included, is there any
> reason why you checked for the existence of the
> session.FormStateManager both outside and inside the cflock?
> With the first cfif, you already have tested for its existence.
The double <cflock> is a safe-guard against double initialisation.
It's possible that two threads (A and B) both run the first
structKeyExists() check at the same time, or at least close enough that
the result is they both enter the <cfif>. Thread A then obtains the
write lock and performs the initialisation; meanwhile thread B is
waiting on the lock. Once A has released the lock, thread B then
obtains the lock it's been waiting for and performs the same
initialisation.
Adding the extra <cfif> within the lock means that the intialisation
will only occur the once. This has been covered quite a few times --
check this post for an example and further explanation:
http://short.badpen.com/?BJNW8673
Tim.
--
-------------------------------------------------------
TB: http://tim.bla.ir/ Tech: http://tech.badpen.com/
-------------------------------------------------------
RAWNET LTD - independent digital media agency
"We are big, we are funny and we are clever!"
http://www.rawnet.com/
-------------------------------------------------------
This message may contain information which is legally
privileged and/or confidential. If you are not the
intended recipient, you are hereby notified that any
unauthorised disclosure, copying, distribution or use
of this information is strictly prohibited. Such
notification notwithstanding, any comments, opinions,
information or conclusions expressed in this message
are those of the originator, not of rawnet limited,
unless otherwise explicitly and independently indicated
by an authorised representative of rawnet limited.
-------------------------------------------------------
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to
[email protected] with the words 'unsubscribe cfcdev' as the subject of the
email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
(www.cfxhosting.com).
An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]