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.



542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
# File 'lib/vivarium.rb', line 542

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



562
563
564
# File 'lib/vivarium.rb', line 562

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

#unregister_pid(pid) ⇒ Object



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

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