Class: InternetHakai::RequestPool
Constant Summary
collapse
- UNIQUE_BY_THREAD =
false
Instance Method Summary
collapse
Methods inherited from BaseHandler
clear, clearall, get_class, get_config, get_handler, get_instance, get_instance_thread, get_thread_id, #on_create, set_config, set_thread_id, unique_by_thread?
Constructor Details
Returns a new instance of RequestPool.
5
6
7
8
9
|
# File 'lib/internethakai/executor.rb', line 5
def initialize id
@queue = Queue::new
@enable = true
@closed = false
end
|
Instance Method Details
#add(action) ⇒ Object
14
15
16
17
|
# File 'lib/internethakai/executor.rb', line 14
def add action
return unless @enable
@queue.enq(action)
end
|
#clear ⇒ Object
10
11
12
13
|
# File 'lib/internethakai/executor.rb', line 10
def clear
@queue.clear
@queue = Queue::new
end
|
#close ⇒ Object
30
31
32
33
34
35
36
|
# File 'lib/internethakai/executor.rb', line 30
def close
@closed = true
1.upto(@queue.num_waiting) do
@queue.enq(-1)
end
@queue.clear
end
|
#empty? ⇒ Boolean
18
19
20
|
# File 'lib/internethakai/executor.rb', line 18
def empty?
@queue.empty?
end
|
#get ⇒ Object
21
22
23
24
25
26
27
28
29
|
# File 'lib/internethakai/executor.rb', line 21
def get
return if @closed
r = @queue.deq
if ! @enable and @queue.empty?
close
end
return r
end
|
#quit ⇒ Object
37
38
39
40
41
|
# File 'lib/internethakai/executor.rb', line 37
def quit
@enable = false
close if @queue.empty?
end
|