Class: Async::Wrapper Deprecated

Inherits:
Object
  • Object
show all
Defined in:
lib/async/wrapper.rb

Overview

Deprecated.

With no replacement. Prefer native interfaces.

Represents an asynchronous IO within a reactor.

Defined Under Namespace

Classes: Cancelled

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io, reactor = nil) ⇒ Wrapper

Returns a new instance of Wrapper.



17
18
19
20
21
22
# File 'lib/async/wrapper.rb', line 17

def initialize(io, reactor = nil)
	@io = io
	@reactor = reactor
	
	@timeout = nil
end

Instance Attribute Details

#ioObject (readonly)

The underlying native ‘io`.



32
33
34
# File 'lib/async/wrapper.rb', line 32

def io
  @io
end

#reactorObject

Returns the value of attribute reactor.



24
25
26
# File 'lib/async/wrapper.rb', line 24

def reactor
  @reactor
end

Instance Method Details

#closeObject

Close the underlying IO.



56
57
58
# File 'lib/async/wrapper.rb', line 56

def close
	@io.close
end

#closed?Boolean

Whether the underlying IO is closed.

Returns:

  • (Boolean)


61
62
63
# File 'lib/async/wrapper.rb', line 61

def closed?
	@io.closed?
end

#dupObject

Dup the underlying IO.



27
28
29
# File 'lib/async/wrapper.rb', line 27

def dup
	self.class.new(@io.dup)
end

#wait_any(timeout = @timeout) ⇒ Object

Wait fo the io to become either readable or writable.



51
52
53
# File 'lib/async/wrapper.rb', line 51

def wait_any(timeout = @timeout)
	@io.to_io.wait(::IO::READABLE|::IO::WRITABLE|::IO::PRIORITY, timeout) or raise TimeoutError
end

#wait_priority(timeout = @timeout) ⇒ Object

Wait for the io to become writable.



40
41
42
# File 'lib/async/wrapper.rb', line 40

def wait_priority(timeout = @timeout)
	@io.to_io.wait_priority(timeout) or raise TimeoutError
end

#wait_readable(timeout = @timeout) ⇒ Object

Wait for the io to become readable.



35
36
37
# File 'lib/async/wrapper.rb', line 35

def wait_readable(timeout = @timeout)
	@io.to_io.wait_readable(timeout) or raise TimeoutError
end

#wait_writable(timeout = @timeout) ⇒ Object

Wait for the io to become writable.



45
46
47
# File 'lib/async/wrapper.rb', line 45

def wait_writable(timeout = @timeout)
	@io.to_io.wait_writable(timeout) or raise TimeoutError
end