开发者

What is the correct sequence in which cflock releases when using multiple locks in different functions?

Given the following scenario, I would like to know if functionOneLock releases itself before functionTwoLock is triggered, or does it wait until functionTwoLock releases first?

<!--- functionOne() --->
<cffunction name="functionOne">
<cflock name="functionOneLock" type="exclusive">
   <!--- do something --->
   <cfset functionTwo()>
</cflock>
</cffunction>

<!--- fun开发者_开发百科ctionTwo() --->
<cffunction name="functionTwo">
<cflock name="functionTwoLock" type="exclusive">
   <!--- do something here --->
</cflock>
</cffunction>


I presume you are calling functionOne() from functionTwo(), like so:

<!--- functionOne() --->
<cffunction name="functionOne">
<cflock name="functionOneLock" type="exclusive">
   <!--- do something --->
   <cfset functionTwo() />
</cflock>
</cffunction>

Since you are using named locks, your thread of execution will enter functionOneLock then within that call the other function thus entering functionTwoLock. It will then complete the code within that lock before returning from that function and completing functionOneLock.

So to answer your question functionOneLock will have to wait for functionTwoLock to complete.

Hope that helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜