VMware Cloud Community
LaxmiRagi
Enthusiast
Enthusiast
Jump to solution

How does the "LockingSystem" function works?

Hi There,

I just wanted to know that, how the "LockingSystem" function works?

anybody, please help me out to understand with an example.

Regards,

Laxmi

0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi,

There are some sample code here in the forum, for example in https://communities.vmware.com/thread/418796

Basically, LockingSystem.lock(...,...) and LockingSystem.lockandWait(...,...) creates a record in the vRO database to mark some object (the first parameter in these functions) as 'locked', and respectively LockingSystem.unlock(...,...) is used to 'unlock' the object.

Note that the object is not indeed locked (which is not possible in general case), it is just marked as locked. So it is up to your code to respect the locked state of the object by trying to acquire a lock to it before any operation with the object that could potentially modify/mutate it.

Also, it is essential to ensure that all objects your code lock will be unlocked after you finish with your modifications.

View solution in original post

0 Kudos
2 Replies
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi,

There are some sample code here in the forum, for example in https://communities.vmware.com/thread/418796

Basically, LockingSystem.lock(...,...) and LockingSystem.lockandWait(...,...) creates a record in the vRO database to mark some object (the first parameter in these functions) as 'locked', and respectively LockingSystem.unlock(...,...) is used to 'unlock' the object.

Note that the object is not indeed locked (which is not possible in general case), it is just marked as locked. So it is up to your code to respect the locked state of the object by trying to acquire a lock to it before any operation with the object that could potentially modify/mutate it.

Also, it is essential to ensure that all objects your code lock will be unlocked after you finish with your modifications.

0 Kudos
LaxmiRagi
Enthusiast
Enthusiast
Jump to solution

Got it.Thank you Ilian Iliev sir.

0 Kudos