Class: Concurrent::Channel::WaitableList

Inherits:
Synchronization::Object
  • Object
show all
Defined in:
lib/concurrent/channel/waitable_list.rb

Instance Method Summary collapse

Constructor Details

#initializeWaitableList

Returns a new instance of WaitableList.



10
11
12
13
# File 'lib/concurrent/channel/waitable_list.rb', line 10

def initialize
  super()
  synchronize { ns_initialize }
end

Instance Method Details

#delete(value) ⇒ Object



30
31
32
# File 'lib/concurrent/channel/waitable_list.rb', line 30

def delete(value)
  synchronize { @list.delete(value) }
end

#empty?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/concurrent/channel/waitable_list.rb', line 19

def empty?
  synchronize { @list.empty? }
end

#put(value) ⇒ Object



23
24
25
26
27
28
# File 'lib/concurrent/channel/waitable_list.rb', line 23

def put(value)
  synchronize do
    @list << value
    ns_signal
  end
end

#sizeObject



15
16
17
# File 'lib/concurrent/channel/waitable_list.rb', line 15

def size
  synchronize { @list.size }
end

#takeObject



34
35
36
37
38
39
# File 'lib/concurrent/channel/waitable_list.rb', line 34

def take
  synchronize do
    ns_wait_until { !@list.empty? }
    @list.shift
  end
end