CFLock identify anonymous locks and latches

I'm new to CFLock, but have recently read on staves cflock and variable, etc. I feel that I have a solid understanding of the situation. In the documentation, I found this snipit I'm having problems understanding.

"Lock scopes and names.
The cflock tag prevented concurrent access to sections of the code, not variables. If you have two sections of the code that access the same variable, they must be synchronized to prevent them from running at the same time. This by identifying the locks with the same scope or name attributes.

Note: ColdFusion does not require you to identify exclusive locks. If you omit the identifier, the lock is anonymous and you cannot synchronize the code in the tag cflock with another code block. Anonymous locks do not lead to errors when they protect a resource that is used in a single code block, but they are of bad programming practice. You must always identify read-only locks.
"

When they are referring to the anonymous locks, they suggest that you use the name option compared to the scope within the cflock tag option? See the examples below:

< name cflock = "Logoutcount" type = "exclusive" timeout = "10" >
< cfset application.logoutcount = application.logoutcount - 1 >
< / cflock >

OR

< cflock scope = "Application" type = "exclusive" timeout = "10" >
< cfset application.logoutcount = application.logoutcount - 1 >
< / cflock >

I guess that if the scope and / variable were the session level, I would just change the application to the session.

What I'm trying to get clarification on here is as well, herds must be created using the name attribute or the scope attribute. I can't find much in the way of documentation pertaining to this matter.

I think you're right. After I read your response, I re - read. I missed the sentence as follows "You do this by identifying the locks with the same scope or name attributes.".

Thanks for pointing it out. Makes sense!

Tags: ColdFusion

Similar Questions

Maybe you are looking for