Class: Cql::Io::Unblocker
- Inherits:
-
Object
- Object
- Cql::Io::Unblocker
- Defined in:
- lib/cql/io/io_reactor.rb
Instance Method Summary collapse
- #close ⇒ Object
- #closed? ⇒ Boolean
- #connected? ⇒ Boolean
- #connecting? ⇒ Boolean
-
#initialize ⇒ Unblocker
constructor
A new instance of Unblocker.
- #read ⇒ Object
- #to_io ⇒ Object
- #to_s ⇒ Object
- #unblock! ⇒ Object
- #writable? ⇒ Boolean
Constructor Details
#initialize ⇒ Unblocker
Returns a new instance of Unblocker.
210 211 212 213 |
# File 'lib/cql/io/io_reactor.rb', line 210 def initialize @out, @in = IO.pipe @lock = Mutex.new end |
Instance Method Details
#close ⇒ Object
241 242 243 244 245 246 |
# File 'lib/cql/io/io_reactor.rb', line 241 def close @in.close @out.close @in = nil @out = nil end |
#closed? ⇒ Boolean
227 228 229 |
# File 'lib/cql/io/io_reactor.rb', line 227 def closed? @in.nil? end |
#connected? ⇒ Boolean
215 216 217 |
# File 'lib/cql/io/io_reactor.rb', line 215 def connected? true end |
#connecting? ⇒ Boolean
219 220 221 |
# File 'lib/cql/io/io_reactor.rb', line 219 def connecting? false end |
#read ⇒ Object
237 238 239 |
# File 'lib/cql/io/io_reactor.rb', line 237 def read @out.read_nonblock(2**16) end |
#to_io ⇒ Object
248 249 250 |
# File 'lib/cql/io/io_reactor.rb', line 248 def to_io @out end |
#to_s ⇒ Object
252 253 254 |
# File 'lib/cql/io/io_reactor.rb', line 252 def to_s %(#<#{self.class.name}>) end |
#unblock! ⇒ Object
231 232 233 234 235 |
# File 'lib/cql/io/io_reactor.rb', line 231 def unblock! @lock.synchronize do @in.write(PING_BYTE) end end |
#writable? ⇒ Boolean
223 224 225 |
# File 'lib/cql/io/io_reactor.rb', line 223 def writable? false end |