initial
[raindrops.git] / lib / raindrops.rb
blob693358af7bf534995f69fddc58f02db6f39d5041
1 # -*- encoding: binary -*-
2 class Raindrops
4   # Used to represent the number of +active+ and +queued+ sockets for
5   # a single listen socket across all threads and processes on a
6   # machine.
7   #
8   # For TCP listeners, only sockets in the TCP_ESTABLISHED state are
9   # accounted for.  For Unix domain listeners, only CONNECTING and
10   # CONNECTED Unix domain sockets are accounted for.
11   #
12   # +active+ connections is the number of accept()-ed but not-yet-closed
13   # sockets in all threads/processes sharing the given listener.
14   #
15   # +queued+ connections is the number of un-accept()-ed sockets in the
16   # queue of a given listen socket.
17   #
18   # These stats are currently only available under Linux
19   class ListenStats < Struct.new(:active, :queued)
21     # the sum of +active+ and +queued+ sockets
22     def total
23       active + queued
24     end
25   end
27   # TODO: pure Ruby version for single processes
28   require 'raindrops_ext'
30   autoload :Struct, 'raindrops/struct'
31   autoload :Middleware, 'raindrops/middleware'
32 end