lib/prometheus/client/helper/mmaped_file.rb in prometheus-client-mmap-0.7.0.beta21 vs lib/prometheus/client/helper/mmaped_file.rb in prometheus-client-mmap-0.7.0.beta22

- old
+ new

@@ -22,25 +22,23 @@ def used=(value) self[0..3] = [value].pack('l') end - def add_entry(data, value) + def try_add_entry(data, value) self.used = START_POSITION if used.zero? # Pad to be 8-byte aligned. padded = data + (' ' * (8 - (data.length + 4) % 8)) entry = [data.length, padded, value].pack("lA#{padded.length}d") used_ = used - while (used_ + entry.length) > @size do - extend(size) - @size = File.size(filepath) - end + return false if (used_ + entry.length) > @size self[used_..used_ + entry.length] = entry - self.used = used_ + entry.length + + true end def close munmap end