Method: Rev::Loop#initialize
- Defined in:
-
lib/rev/loop.rb,
ext/rev/rev_loop.c
Create a new Rev::Loop
Options:
:skip_environment (boolean)
Ignore the $LIBEV_FLAGS environment variable
:fork_check (boolean)
Enable autodetection of forks
:backend
Choose the default backend, one (or many in an array) of:
:select (most platforms)
:poll (most platforms except Windows)
:epoll (Linux)
:kqueue (BSD/Mac OS X)
:port (Solaris 10)
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/rev/loop.rb', line 49 def initialize( = {}) @watchers = {} @active_watchers = 0 flags = 0 .each do |option, value| case option when :skip_environment flags |= EVFLAG_NOEV if value when :fork_check flags |= EVFLAG_FORKCHECK if value when :backend value = [value] unless value.is_a? Array value.each do |backend| case backend when :select then flags |= EVBACKEND_SELECT when :poll then flags |= EVBACKEND_POLL when :epoll then flags |= EVBACKEND_EPOLL when :kqueue then flags |= EVBACKEND_KQUEUE when :port then flags |= EVBACKEND_PORT else raise ArgumentError, "no such backend: #{backend}" end end else raise ArgumentError, "no such option: #{option}" end end @loop = ev_loop_new(flags) end |