Class: Fairy::Here

Inherits:
IOFilter show all
Includes:
Enumerable
Defined in:
lib/fairy/client/here.rb

Direct Known Subclasses

OutputLocalFile

Defined Under Namespace

Modules: Interface

Instance Method Summary collapse

Methods inherited from IOFilter

#input=

Methods inherited from Filter

#backend, #backend=, #backend_class, #def_pool_variable

Constructor Details

#initialize(fairy, opts = nil) ⇒ Here

Returns a new instance of Here.



22
23
24
# File 'lib/fairy/client/here.rb', line 22

def initialize(fairy, opts = nil)
  super
end

Instance Method Details

#backend_class_nameObject



26
27
28
# File 'lib/fairy/client/here.rb', line 26

def backend_class_name
  "CHere"
end

#each(&block) ⇒ Object

def each(&block)

  backend.each{|e| block.call e}
end


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/fairy/client/here.rb', line 34

def each(&block)
  policy = @opts[:prequeuing_policy]
  
  imports = Queue.new

  parent_thread = Thread.current
  
  Thread.start do
	begin
	  backend.each_node do |node|
 node.start_export
 import = Import.new(policy)
 import.set_log_callback do |n, key| 
   Log::verbose(self, "IMPORT POP key=#{key}: #{n}")
 end
 import.no_import = 1
 node.export.output = import
 imports.push import
 nil # 消すな!!(BUG#250対応)
	  end
	  imports.push nil
	rescue Exception
	  parent_thread.raise $!
	end
  end

  while imp = imports.pop
	imp.each do |e|
	  block.call e
	end
  end
end

#each_with_bjobeach(&block) ⇒ Object



67
68
69
70
71
72
73
# File 'lib/fairy/client/here.rb', line 67

def each_with_bjobeach(&block)
  backend.each_buf do |buf|
	buf.each &block
	# GCの問題
	buf = nil
  end
end

#to_aObject



75
76
77
78
79
# File 'lib/fairy/client/here.rb', line 75

def to_a
  ary = []
  backend.each{|e| ary.push e}
  ary
end