<CFLOCK> Tag - ColdFusion


>> Return to ColdFusion Tag Index

The <CFLOCK> tag allows you ...





  <CFLOCK> Comments from Macromedia LiveDocsLiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-p71.htm
FYI a cfreturn inside a cflock seems to work in CF 7.02 - not saying that it's a best practice or that the engineers have checked it out. That said it is a very common use case if you are trying to provide safe concurrent access to a bean property's getter method.

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-p71.htm
<CFRETURN> within <CFLOCK>

Do you mean it's not good practice or it produces an error, i.e., the lock is not released?

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-p71.htm
It should be noted that functions cannot return a value from within a cflock. The following is a simple example to demonstrate my point.

<cfoutput>#getVar("uservo")#</cfoutput>

<cffunction name="getVar" access="public" returntype="any" output="false"
displayname="" hint="Retrieves a variable from the session.">
<cfargument name="varName" type="variablename" required="true"
displayname="" hint="Variable to retrieve from session." />

<cflock name="readSessionVariable" timeout="10" type="readonly">
<cfif structKeyExists(session,arguments.varName)>
<cfreturn evaluate("session." & arguments.varName)/>
</cfif>
</cflock>
<cfdump var="qadfsdf"><cfabort >
<cfthrow message="Element #arguments.varName# is undefined in Session." type="session"/>

<cfreturn/>
</cffunction>

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-p71.htm
This page should indicate that if you set timeout="0", the timeout is determined by the "Timeout Requests after x" setting in the ColdFusion MX Administrator Settings page, if that setting is enabled. If the Administrator "Timeout Requests after x" setting is not enabled and you set the timeout attribute to 0, ColdFusion can wait indefinitely to obtain the lock.

Also, in the first deadlock example, it is not obvious that the line with the two Deadlock: entries is part of the table and has two columns.



[Top]


Recommended Books

[Top]

Web Sites

[Top]

Copyright © 2003- 2008, Orville Paul Chomer, All Rights Reserved