Module: DMiqVimSync

Included in:
DMiqVim, MiqVimDataStore
Defined in:
lib/VMwareWebService/DMiqVimSync.rb

Instance Method Summary collapse

Instance Method Details

#dupObj(obj) ⇒ Object

This method is called - with the cacheLock held - when returning an object from the cache to the client. It used to produce a full recursive copy of the object before releasing the lock. When used in the broker, the DRB layer would then marshal the copy of the object to return it to the remote client. This new scheme enables us to hold the cacheLock until after DRB marshals the object, eliminating the need for this method to produce a full recursive copy.

The lock count of the cacheLock is incremented, so when this method’s caller releases the lock, the lock will still be held. The object to be returned and the cacheLock are wraped in a MiqDrbReturn object and returned to the DRB layer, which will marshal the object and release the lock. See below.



14
15
16
17
18
19
# File 'lib/VMwareWebService/DMiqVimSync.rb', line 14

def dupObj(obj)
  return(obj) unless @cacheLock.sync_locked?
  $vim_log.debug "DMiqVim::dupObj: LOCKING [#{Thread.current.object_id}] <#{obj.object_id}>" if $vim_log.debug?
  @cacheLock.sync_lock(:SH)
  (MiqDrbReturn.new(obj, @cacheLock))
end