rdoc: 100% documentation coverage!
[raindrops.git] / lib / raindrops.rb
blob54760a68852de313e6285a22457d77a53dde2753
1 # -*- encoding: binary -*-
3 # Each Raindrops object is a container that holds several counters.
4 # It is internally a page-aligned, shared memory area that allows
5 # atomic increments, decrements, assignments and reads without any
6 # locking.
8 #   rd = Raindrops.new 4
9 #   rd.incr(0, 1)   -> 1
10 #   rd.to_ary       -> [ 1, 0, 0, 0 ]
12 class Raindrops
14   # Used to represent the number of +active+ and +queued+ sockets for
15   # a single listen socket across all threads and processes on a
16   # machine.
17   #
18   # For TCP listeners, only sockets in the TCP_ESTABLISHED state are
19   # accounted for.  For Unix domain listeners, only CONNECTING and
20   # CONNECTED Unix domain sockets are accounted for.
21   #
22   # +active+ connections is the number of accept()-ed but not-yet-closed
23   # sockets in all threads/processes sharing the given listener.
24   #
25   # +queued+ connections is the number of un-accept()-ed sockets in the
26   # queue of a given listen socket.
27   #
28   # These stats are currently only available under \Linux
29   class ListenStats < Struct.new(:active, :queued)
31     # the sum of +active+ and +queued+ sockets
32     def total
33       active + queued
34     end
35   end
37   autoload :Linux, 'raindrops/linux'
38   autoload :Struct, 'raindrops/struct'
39   autoload :Middleware, 'raindrops/middleware'
40   autoload :Aggregate, 'raindrops/aggregate'
41   autoload :LastDataRecv, 'raindrops/last_data_recv'
42 end
43 require 'raindrops_ext'