class Elf::Utilities::FilePool
Pool for ELF files.
This pool is useful for tools that recurse over a tree of dependencies to avoid creating multiple instances of Elf::File
being open and accessing the same file.
Notes:
- Instances might be re-created if no strong references left to specific Elf::File - New instance will be created on access if previous one were closed
Public Class Methods
[](file)
click to toggle source
# File lib/elf/utils/pool.rb, line 36 def self.[](file) realfile = Pathname.new(file).realpath cached = @pool[realfile].__getobj__ rescue nil if cached.nil? || cached.closed? cached = Elf::File.new(realfile) @pool[realfile] = WeakRef.new(cached) end cached end