Class: Net::IMAP

Inherits:
Object
  • Object
show all
Defined in:
lib/net/imap/idle.rb

Instance Method Summary collapse

Instance Method Details

#idle(&response_handler) ⇒ Object

Raises:

  • (LocalJumpError)


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/net/imap/idle.rb', line 11

def idle(&response_handler)
  raise LocalJumpError, "no block given" unless response_handler

  response = nil

  synchronize do
    tag = Thread.current[:net_imap_tag] = generate_tag
    put_string "#{tag} IDLE#{CRLF}"

    begin
      add_response_handler response_handler

      @idle_done_cond = new_cond
      @idle_done_cond.wait
      @idle_done_cond = nil
    ensure
      remove_response_handler response_handler
      put_string "DONE#{CRLF}"
      response = get_tagged_response tag
    end
  end

  response
end

#idle_doneObject

Raises:

  • (Net::IMAP::Error)


39
40
41
42
43
44
45
# File 'lib/net/imap/idle.rb', line 39

def idle_done
  raise Net::IMAP::Error, 'not during idle' unless @idle_done_cond

  synchronize do
    @idle_done_cond.signal
  end
end