Class: V8::Portal::Proxies::ClearRubyProxy
- Defined in:
- lib/v8/portal/proxies.rb
Overview
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)
Instance Method Summary collapse
-
#call(proxy_id) ⇒ Object
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.
-
#initialize(rb2js, js2rb) ⇒ ClearRubyProxy
constructor
A new instance of ClearRubyProxy.
Constructor Details
#initialize(rb2js, js2rb) ⇒ ClearRubyProxy
Returns a new instance of ClearRubyProxy.
130 131 132 |
# File 'lib/v8/portal/proxies.rb', line 130 def initialize(rb2js, js2rb) @rb2js, @js2rb = rb2js, js2rb end |
Instance Method Details
#call(proxy_id) ⇒ Object
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
138 139 140 141 142 143 144 145 146 147 |
# 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 |