Class: Fairy::PFindResult

Inherits:
PIOFilter show all
Defined in:
lib/fairy/node/p-find.rb

Constant Summary

Constants inherited from PIOFilter

Fairy::PIOFilter::ST_WAIT_IMPORT

Constants inherited from PFilter

Fairy::PFilter::END_OF_STREAM, Fairy::PFilter::ST_ACTIVATE, Fairy::PFilter::ST_FINISH, Fairy::PFilter::ST_INIT

Instance Attribute Summary

Attributes inherited from PFilter

#IGNORE_EXCEPTION, #id, #log_id, #ntask

Instance Method Summary collapse

Methods inherited from PFilter

#abort_running, #basic_start, #break_running, #global_break, #global_break_from_other, #handle_exception, #key, #key=, #next, #no, #no=, #notice_status, #processor, #start, #start_export, #start_watch_status, #status=, #terminate, #terminate_proc

Constructor Details

#initialize(*args) ⇒ PFindResult

Returns a new instance of PFindResult.



64
65
66
67
68
69
70
# File 'lib/fairy/node/p-find.rb', line 64

def initialize(*args)
  super

  @value = :__FAIRY_NO_VALUE__
  @value_mutex = Mutex.new
  @value_cv = XThread::ConditionVariable.new
end

Instance Method Details

#each(&block) ⇒ Object



82
83
84
# File 'lib/fairy/node/p-find.rb', line 82

def each(&block)
  block.call value
end

#input=(input) ⇒ Object



72
73
74
75
76
77
78
# File 'lib/fairy/node/p-find.rb', line 72

def input=(input)
  super

  start do
	self.start_find
  end
end

#start_findObject



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/fairy/node/p-find.rb', line 95

def start_find
  find = false
  @input.each do |e|
	# 最初の要素以外空読み
	next if find 
	find = e

	@value = find
	@value_cv.broadcast 
#	@export.push find
	# ちょっと気になる...
#	@export.push END_OF_STREAM

	@bjob.update_find
  end
end

#super_eachObject



80
# File 'lib/fairy/node/p-find.rb', line 80

alias super_each each

#valueObject



86
87
88
89
90
91
92
93
# File 'lib/fairy/node/p-find.rb', line 86

def value
  @value_mutex.synchronize do
	while @value == :__FAIRY_NO_VALUE__
	  @value_cv.wait(@value_mutex)
	end
	@value
  end
end