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.



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

def initialize(fairy, opts = nil)
  super
end

Instance Method Details

#backend_class_nameObject



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

def backend_class_name
  "CHere"
end

#each(&block) ⇒ Object

def each(&block)

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


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
66
# File 'lib/fairy/client/here.rb', line 35

def each(&block)
  policy = @opts[:prequeuing_policy]
  
  imports = XThread::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



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

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

#to_aObject



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

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