Class: NIO::Monitor

Inherits:
Object
  • Object
show all
Defined in:
lib/nio/monitor.rb,
lib/nio/jruby/monitor.rb,
ext/nio4r/monitor.c,
ext/nio4r/selector.c

Overview

Monitors watch Channels for specific events

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io, selection_key) ⇒ Object

Methods



8
9
10
11
# File 'lib/nio/monitor.rb', line 8

def initialize(io, interests)
  @io, @interests = io, interests
  @closed = false
end

Instance Attribute Details

#interestsObject (readonly)

Obtain the interests for this monitor



14
15
16
# File 'lib/nio/jruby/monitor.rb', line 14

def interests
  @interests
end

#ioObject

Returns the value of attribute io.



21
22
23
# File 'ext/nio4r/monitor.c', line 21

def io
  @io
end

#readinessObject

What is the IO object ready for?



19
20
21
# File 'lib/nio/jruby/monitor.rb', line 19

def readiness
  @readiness
end

#valueObject

Returns the value of attribute value.



25
26
27
# File 'ext/nio4r/monitor.c', line 25

def value
  @value
end

Instance Method Details

#closeObject

Deactivate this monitor



28
29
30
# File 'lib/nio/monitor.rb', line 28

def close
  @closed = true
end

#closed?Boolean

Is this monitor closed?

Returns:

  • (Boolean)


25
# File 'lib/nio/monitor.rb', line 25

def closed?; @closed; end

#readable?Boolean

Is the IO object readable?

Returns:

  • (Boolean)


14
15
16
# File 'lib/nio/monitor.rb', line 14

def readable?
  readiness == :r || readiness == :rw
end

#writable?Boolean Also known as: writeable?

Is the IO object writable?

Returns:

  • (Boolean)


19
20
21
# File 'lib/nio/monitor.rb', line 19

def writable?
  readiness == :w || readiness == :rw
end