Class: RbBCC::ArrayTable
Instance Attribute Summary
Attributes inherited from TableBase
#bpf, #flags, #keysize, #keytype, #leafsize, #leaftype, #map_fd, #map_id, #name, #ttype
Instance Method Summary collapse
- #clearitem(key) ⇒ Object
- #delete(key) ⇒ Object
- #each(&b) ⇒ Object
-
#initialize(bpf, map_id, map_fd, keytype, leaftype, name: nil) ⇒ ArrayTable
constructor
A new instance of ArrayTable.
-
#size ⇒ Object
(also: #length)
We now emulate the Array class of Ruby.
Methods inherited from TableBase
#[], #[]=, #clear, #each_key, #each_pair, #each_value, #fetch, #items, #next, #print_linear_hist, #print_log2_hist, #structured_key?, #values
Methods included from CPUHelper
_read_cpu_range, get_online_cpus, get_possible_cpus
Constructor Details
#initialize(bpf, map_id, map_fd, keytype, leaftype, name: nil) ⇒ ArrayTable
Returns a new instance of ArrayTable.
303 304 305 306 |
# File 'lib/rbbcc/table.rb', line 303 def initialize(bpf, map_id, map_fd, keytype, leaftype, name: nil) super @max_entries = Clib.bpf_table_max_entries_id(bpf.module, map_id) end |
Instance Method Details
#clearitem(key) ⇒ Object
314 315 316 |
# File 'lib/rbbcc/table.rb', line 314 def clearitem(key) self[key] = byref(0, @leafsize) end |
#delete(key) ⇒ Object
318 319 320 321 |
# File 'lib/rbbcc/table.rb', line 318 def delete(key) # Delete in Array type does not have an effect, so zero out instead clearitem(key) end |
#each(&b) ⇒ Object
323 324 325 326 327 |
# File 'lib/rbbcc/table.rb', line 323 def each(&b) each_value do |v| b.call(v.to_bcc_value) end end |
#size ⇒ Object Also known as: length
We now emulate the Array class of Ruby
309 310 311 |
# File 'lib/rbbcc/table.rb', line 309 def size @max_entries end |