class V8::Portal::Proxies::ClearRubyProxy

@Private Remove the linkage between a Ruby proxy and a native JavaScript object. In general, this object is registered as a finalizer on the Ruby proxy itself, so that when it is garbage collected, it releases the back reference to the native JavaScript object.

It is important to do this as soon as is reasonably possible so that the native JavaScript object can itself be garbage collected (provided there are no other references to it)

Public Class Methods

new(rb2js, js2rb) click to toggle source
# File lib/v8/portal/proxies.rb, line 130
def initialize(rb2js, js2rb)
  @rb2js, @js2rb = rb2js, js2rb
end

Public Instance Methods

call(proxy_id) click to toggle source

takes the object id of a Ruby proxy that has been garbage collected and releases the reference to the native JavaScript object that it was bound to. @param proxy_id the proxy id of the garbage collected Ruby proxy

# File lib/v8/portal/proxies.rb, line 138
def call(proxy_id)
  # TODO: this if-check should be synchronized, so that if called manually
  # it will not conflict with the finalization thread. It's not so heinous
  # if the refererence gets cleared twice, but we definiteily dont't want
  # to double-decrement the v8 GC hint.
  if js = @rb2js[proxy_id]
    @rb2js.delete(proxy_id)
    @js2rb.delete(js)
  end
end