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.



512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
# File 'lib/vivarium.rb', line 512

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



532
533
534
# File 'lib/vivarium.rb', line 532

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

#unregister_pid(pid) ⇒ Object



536
537
538
539
540
541
# File 'lib/vivarium.rb', line 536

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