Class: Redis::Lists::DeferredPop

Inherits:
Object
  • Object
show all
Includes:
EventMachine::Deferrable
Defined in:
lib/redis/lists.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(database, timeout_secs, *keys) ⇒ DeferredPop

Returns a new instance of DeferredPop.



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/redis/lists.rb', line 11

def initialize database, timeout_secs, *keys
  @database = database
  @keys = keys
  timeout timeout_secs if timeout_secs > 0
  errback { unbind }
  callback { unbind }
  keys.each do |key|
    (@database.blocked_pops[key] ||= []).push self
  end
  @bound = true
end

Instance Attribute Details

#boundObject (readonly)

Returns the value of attribute bound.



9
10
11
# File 'lib/redis/lists.rb', line 9

def bound
  @bound
end

Instance Method Details

#unbindObject



23
24
25
26
27
28
29
30
31
# File 'lib/redis/lists.rb', line 23

def unbind
  return unless @bound
  @keys.each do |key|
    key_df_list = @database.blocked_pops[key]
    next unless key_df_list
    key_df_list.delete_if { |e| e == self }
  end
  @bound = false
end