Class: Phlex::FIFO Private

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

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Direct Known Subclasses

AttributeCache

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(max_bytesize: 2_000, max_value_bytesize: 2_000) ⇒ FIFO

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of FIFO.



5
6
7
8
9
10
11
# File 'lib/phlex/fifo.rb', line 5

def initialize(max_bytesize: 2_000, max_value_bytesize: 2_000)
	@store = {}
	@max_bytesize = max_bytesize
	@max_value_bytesize = max_value_bytesize
	@bytesize = 0
	@mutex = Monitor.new
end

Instance Attribute Details

#bytesize ⇒ Object (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



13
14
15
# File 'lib/phlex/fifo.rb', line 13

def bytesize
  @bytesize
end

#max_bytesize ⇒ Object (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



13
14
15
# File 'lib/phlex/fifo.rb', line 13

def max_bytesize
  @max_bytesize
end

Instance Method Details

#[](key) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



21
22
23
24
# File 'lib/phlex/fifo.rb', line 21

def [](key)
	k, v = @store[key.hash]
	v if k.eql?(key)
end

#[]=(key, value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



26
27
28
# File 'lib/phlex/fifo.rb', line 26

def []=(key, value)
	store(key.hash, key, value)
end

#clear ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



53
54
55
56
57
58
# File 'lib/phlex/fifo.rb', line 53

def clear
	@mutex.synchronize do
		@store.clear
		@bytesize = 0
	end
end

#expand(bytes) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



15
16
17
18
19
# File 'lib/phlex/fifo.rb', line 15

def expand(bytes)
	@mutex.synchronize do
		@max_bytesize += bytes
	end
end

#size ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



49
50
51
# File 'lib/phlex/fifo.rb', line 49

def size
	@store.size
end