Module: Mysql2::EM::Client::Watcher

Defined in:
lib/mysql2/em.rb

Instance Method Summary collapse

Instance Method Details

#initialize(client, deferable) ⇒ Object



10
11
12
13
14
# File 'lib/mysql2/em.rb', line 10

def initialize(client, deferable)
  @client = client
  @deferable = deferable
  @is_watching = true
end

#notify_readableObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/mysql2/em.rb', line 16

def notify_readable
  detach
  begin
    result = @client.async_result
  rescue Exception => e
    @deferable.fail(e)
  else
    @deferable.succeed(result)
  end
end

#unbindObject



31
32
33
# File 'lib/mysql2/em.rb', line 31

def unbind
  @is_watching = false
end

#watching?Boolean



27
28
29
# File 'lib/mysql2/em.rb', line 27

def watching?
  @is_watching
end