Class: Vivarium::MapStore

Inherits:
Object
  • Object
show all
Defined in:
lib/vivarium.rb

Instance Method Summary collapse

Constructor Details

#initialize(pin_dir: Vivarium.bpf_pin_dir) ⇒ MapStore

Returns a new instance of MapStore.



548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
# File 'lib/vivarium.rb', line 548

def initialize(pin_dir: Vivarium.bpf_pin_dir)
  @pin_dir = pin_dir
  @config_root_targets = RbBCC::HashTable.from_pin(
    File.join(@pin_dir, "config_root_targets"),
    "unsigned int",
    "unsigned char",
    keysize: 4,
    leafsize: 1
  )
  @config_spawned_targets = RbBCC::HashTable.from_pin(
    File.join(@pin_dir, "config_spawned_targets"),
    "unsigned int",
    "unsigned char",
    keysize: 4,
    leafsize: 1
  )
rescue StandardError => e
  raise Error, "failed to open pinned maps under #{@pin_dir}: #{e.class}: #{e.message}"
end

Instance Method Details

#register_pid(pid) ⇒ Object



568
569
570
# File 'lib/vivarium.rb', line 568

def register_pid(pid)
  @config_root_targets[pid] = 1
end

#unregister_pid(pid) ⇒ Object



572
573
574
575
576
577
# File 'lib/vivarium.rb', line 572

def unregister_pid(pid)
  @config_root_targets.delete(pid)
  @config_spawned_targets.clear
rescue KeyError
  nil
end