Class: Baykit::BayServer::Tours::ReadFileTaxi
- Inherits:
-
Baykit::BayServer::Taxi::Taxi
- Object
- Baykit::BayServer::Taxi::Taxi
- Baykit::BayServer::Tours::ReadFileTaxi
- Includes:
- Agent, Baykit::BayServer::Taxi, Util, Util::Valve
- Defined in:
- lib/baykit/bayserver/tours/read_file_taxi.rb
Instance Attribute Summary collapse
-
#buf ⇒ Object
readonly
Returns the value of attribute buf.
-
#buf_size ⇒ Object
readonly
Returns the value of attribute buf_size.
-
#ch_valid ⇒ Object
readonly
Returns the value of attribute ch_valid.
-
#data_listener ⇒ Object
readonly
Returns the value of attribute data_listener.
-
#infile ⇒ Object
readonly
Returns the value of attribute infile.
-
#lock ⇒ Object
readonly
Returns the value of attribute lock.
-
#running ⇒ Object
readonly
Returns the value of attribute running.
Attributes inherited from Baykit::BayServer::Taxi::Taxi
Instance Method Summary collapse
- #close ⇒ Object
-
#depart ⇒ Object
implements Taxi.
- #init(infile, data_listener) ⇒ Object
-
#initialize(buf_size) ⇒ ReadFileTaxi
constructor
A new instance of ReadFileTaxi.
- #next_run ⇒ Object
-
#open_valve ⇒ Object
implements Valve.
- #to_s ⇒ Object
Methods inherited from Baykit::BayServer::Taxi::Taxi
Constructor Details
#initialize(buf_size) ⇒ ReadFileTaxi
Returns a new instance of ReadFileTaxi.
27 28 29 30 31 32 |
# File 'lib/baykit/bayserver/tours/read_file_taxi.rb', line 27 def initialize(buf_size) super() @buf_size = buf_size @buf = StringUtil.alloc(buf_size) @lock = Monitor.new() end |
Instance Attribute Details
#buf ⇒ Object (readonly)
Returns the value of attribute buf.
22 23 24 |
# File 'lib/baykit/bayserver/tours/read_file_taxi.rb', line 22 def buf @buf end |
#buf_size ⇒ Object (readonly)
Returns the value of attribute buf_size.
23 24 25 |
# File 'lib/baykit/bayserver/tours/read_file_taxi.rb', line 23 def buf_size @buf_size end |
#ch_valid ⇒ Object (readonly)
Returns the value of attribute ch_valid.
20 21 22 |
# File 'lib/baykit/bayserver/tours/read_file_taxi.rb', line 20 def ch_valid @ch_valid end |
#data_listener ⇒ Object (readonly)
Returns the value of attribute data_listener.
21 22 23 |
# File 'lib/baykit/bayserver/tours/read_file_taxi.rb', line 21 def data_listener @data_listener end |
#infile ⇒ Object (readonly)
Returns the value of attribute infile.
19 20 21 |
# File 'lib/baykit/bayserver/tours/read_file_taxi.rb', line 19 def infile @infile end |
#lock ⇒ Object (readonly)
Returns the value of attribute lock.
25 26 27 |
# File 'lib/baykit/bayserver/tours/read_file_taxi.rb', line 25 def lock @lock end |
#running ⇒ Object (readonly)
Returns the value of attribute running.
24 25 26 |
# File 'lib/baykit/bayserver/tours/read_file_taxi.rb', line 24 def running @running end |
Instance Method Details
#close ⇒ Object
94 95 96 97 98 |
# File 'lib/baykit/bayserver/tours/read_file_taxi.rb', line 94 def close() @ch_valid = false @infile.close() @data_listener.notify_close() end |
#depart ⇒ Object
implements Taxi
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/baykit/bayserver/tours/read_file_taxi.rb', line 58 def depart() @lock.synchronize do begin @buf.clear() @infile.read(@buf_size, @buf) if @buf.length == 0 @data_listener.notify_eof() close() return end act = @data_listener.notify_read(@buf, nil) @running = false if act == NextSocketAction::CONTINUE next_run() end rescue Exception => e BayLog.error_e(e) close() end end end |
#init(infile, data_listener) ⇒ Object
38 39 40 41 42 |
# File 'lib/baykit/bayserver/tours/read_file_taxi.rb', line 38 def init(infile, data_listener) @data_listener = data_listener @infile = infile @ch_valid = true end |
#next_run ⇒ Object
85 86 87 88 89 90 91 92 |
# File 'lib/baykit/bayserver/tours/read_file_taxi.rb', line 85 def next_run() if @running # If running, not posted because next run exists return end @running = true TaxiRunner.post(self) end |
#open_valve ⇒ Object
implements Valve
48 49 50 51 52 |
# File 'lib/baykit/bayserver/tours/read_file_taxi.rb', line 48 def open_valve() @lock.synchronize do next_run() end end |
#to_s ⇒ Object
34 35 36 |
# File 'lib/baykit/bayserver/tours/read_file_taxi.rb', line 34 def to_s() return super.to_s() + " " + @data_listener.to_s() end |