Class: Jscall::Imported
- Inherits:
-
Object
- Object
- Jscall::Imported
- Defined in:
- lib/jscall.rb
Overview
outbound references from Ruby to Node
Instance Attribute Summary collapse
-
#objects ⇒ Object
readonly
Returns the value of attribute objects.
Instance Method Summary collapse
- #dead_references ⇒ Object
- #import(index) ⇒ Object
-
#initialize ⇒ Imported
constructor
A new instance of Imported.
-
#kill_canary ⇒ Object
forces dead_references() to check the liveness of references.
Constructor Details
Instance Attribute Details
#objects ⇒ Object (readonly)
Returns the value of attribute objects.
135 136 137 |
# File 'lib/jscall.rb', line 135 def objects @objects end |
Instance Method Details
#dead_references ⇒ Object
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/jscall.rb', line 160 def dead_references() if @canary&.weakref_alive? return [] else @canary = WeakRef.new(RemoteRef.new(-1)) end deads = [] objects = @objects.__getobj__ objects.each_index do |index| wref = objects[index] if !wref.nil? && !wref.weakref_alive? objects[index] = nil deads << index end end deads end |
#import(index) ⇒ Object
143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/jscall.rb', line 143 def import(index) objects = @objects.__getobj__ wref = objects[index] if wref&.weakref_alive? wref.__getobj__ else rref = RemoteRef.new(index) objects[index] = WeakRef.new(rref) rref end end |
#kill_canary ⇒ Object
forces dead_references() to check the liveness of references.
156 157 158 |
# File 'lib/jscall.rb', line 156 def kill_canary @canary = nil end |