Each Raindrops object is a container that holds several counters. It is internally a page-aligned, shared memory area that allows atomic increments, decrements, assignments and reads without any locking.
rd = Raindrops.new 4 rd.incr(0, 1) -> 1 rd.to_ary -> [ 1, 0, 0, 0 ]
Unlike many classes in this package, the core Raindrops class is intended to be portable to all reasonably modern *nix systems supporting mmap(). Please let us know if you have portability issues, patches or pull requests at raindrops-public@yhbt.net
The maximum value a raindrop counter can hold
The size of one page of memory for a mmap()-ed Raindrops region. Typically 4096 bytes under Linux.
The size (in bytes) of a slot in a Raindrops object. This is the size of a word on single CPU systems and the size of the L1 cache line size if detectable.
Defaults to 128 bytes if undetectable.
This is a frozen hash storing the numeric values maps platform-independent symbol keys to platform-dependent numeric values. These states are all valid values for the Raindrops::TCP_Info#state field.
The platform-independent names of the keys in this hash are:
- :ESTABLISHED - :SYN_SENT - :SYN_RECV - :FIN_WAIT1 - :FIN_WAIT2 - :TIME_WAIT - :CLOSE - :CLOSE_WAIT - :LAST_ACK - :LISTEN - :CLOSING
This is only supported on platforms where TCP_Info is supported, currently FreeBSD, OpenBSD, and Linux-based systems.
Raindrops.new(size, io: nil) -> raindrops object source
Initializes a Raindrops object to hold size counters. size is only a hint and the actual number of counters the object has is dependent on the CPU model, number of cores, and page size of the machine. The actual size of the object will always be equal or greater than the specified size. If io is provided, then the Raindrops memory will be backed by the specified file; otherwise, it will allocate anonymous memory. The IO object must respond to truncate, as this is used to set the size of the file. If zero is provided, then the memory region is zeroed prior to returning. This is only meaningful if io is also provided; in that case it controls whether any existing counter values in io are retained (false) or whether it is entirely zeroed (true).
rd[index] -> value source
Returns the value of the slot designated by index
rd[index] = value source
Assigns value to the slot designated by index
rd.capa -> Integer source
Returns the number of slots allocated (but not necessarily used) by the Raindrops object.
rd.decr(index[, number]) -> result source
Decrements the value referred to by the index by number. number defaults to 1 if unspecified.
rd.evaporate! -> nil source
Releases mmap()-ed memory allocated for the Raindrops object back to the OS. The Ruby garbage collector will also release memory automatically when it is not needed, but this forces release under high memory pressure.
rd.incr(index[, number]) -> result source
Increments the value referred to by the index by number. number defaults to 1 if unspecified.
rd.dup -> rd_copy source
Duplicates and snapshots the current state of a Raindrops object. Even if the given Raindrops object is backed by a file, the copy will be backed by independent, anonymously mapped memory.
rd.size -> Integer source
Returns the number of counters a Raindrops object can hold. Due to page alignment, this is always equal or greater than the number of requested slots passed to Raindrops.new
rd.size = new_size source
Increases or decreases the current capacity of our Raindrop. Raises RangeError if new_size is too big or small for the current backing store
rd.to_ary -> Array source
converts the Raindrops structure to an Array
to_io -> IO source
Returns the IO object backing the memory for this raindrop, if one was specified when constructing this Raindrop. If this Raindrop is backed by anonymous memory, this method returns nil.
mail archives: https://yhbt.net/raindrops-public/ http://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/raindrops-public nntps://news.public-inbox.org/inbox.comp.lang.ruby.raindrops nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.lang.ruby.raindrops imaps://yhbt.net/inbox.comp.lang.ruby.raindrops.0 imap://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.lang.ruby.raindrops.0 public: raindrops-public@yhbt.net source code: git clone https://yhbt.net/raindrops.git torsocks git clone http://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/raindrops.git