Class: Cql::Io::Unblocker

Inherits:
Object
  • Object
show all
Defined in:
lib/cql/io/io_reactor.rb

Instance Method Summary collapse

Constructor Details

#initializeUnblocker

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

#closeObject



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

Returns:

  • (Boolean)


227
228
229
# File 'lib/cql/io/io_reactor.rb', line 227

def closed?
  @in.nil?
end

#connected?Boolean

Returns:

  • (Boolean)


215
216
217
# File 'lib/cql/io/io_reactor.rb', line 215

def connected?
  true
end

#connecting?Boolean

Returns:

  • (Boolean)


219
220
221
# File 'lib/cql/io/io_reactor.rb', line 219

def connecting?
  false
end

#readObject



237
238
239
# File 'lib/cql/io/io_reactor.rb', line 237

def read
  @out.read_nonblock(2**16)
end

#to_ioObject



248
249
250
# File 'lib/cql/io/io_reactor.rb', line 248

def to_io
  @out
end

#to_sObject



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

Returns:

  • (Boolean)


223
224
225
# File 'lib/cql/io/io_reactor.rb', line 223

def writable?
  false
end