Class: Vertx::Pump
- Inherits:
-
Object
- Object
- Vertx::Pump
- Defined in:
- /Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/pump.rb
Overview
Instances of this class read items from a ReadStream and write them to a WriteStream. If data can be read faster than it can be written this could result in the write queue of the WriteStream growing without bound, eventually causing it to exhaust all available RAM.
To prevent this, after each write, instances of this class check whether the write queue of the WriteStream is full, and if so, the ReadStream is paused, and a drainHandler
is set on the
WriteStream.
When the WriteStream has processed half of its backlog, the drainHandler
will be
called, which results in the pump resuming the ReadStream.
This class can be used to pump from any ReadStream to any WriteStream, e.g. from an HttpServerRequest to an AsyncFile, or from NetSocket to a WebSocket.
Please see the documentation for more information.
Constant Summary
- @@j_api_type =
Object.new
Class Method Summary (collapse)
- + (Boolean) accept?(obj)
- + (Object) j_api_type
- + (Object) j_class
-
+ (::Vertx::Pump) pump(*args)
Create a new Pump with the given ReadStream and WriteStream and writeQueueMaxSize.
- + (Object) unwrap(obj)
- + (Object) wrap(obj)
Instance Method Summary (collapse)
-
- (Fixnum) numberPumped
Return the total number of items pumped by this pump.
-
- (self) setWriteQueueMaxSize(maxSize)
Set the write queue max size to maxSize.
-
- (self) start
Start the Pump.
-
- (self) stop
Stop the Pump.
Class Method Details
+ (Boolean) accept?(obj)
37 38 39 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/pump.rb', line 37 def @@j_api_type.accept?(obj) obj.class == Pump end |
+ (Object) j_api_type
46 47 48 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/pump.rb', line 46 def self.j_api_type @@j_api_type end |
+ (Object) j_class
49 50 51 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/pump.rb', line 49 def self.j_class Java::IoVertxCoreStreams::Pump.java_class end |
+ (::Vertx::Pump) pump(rs, ws) + (::Vertx::Pump) pump(rs, ws, writeQueueMaxSize)
Pump
with the given ReadStream
and WriteStream
and
writeQueueMaxSize
103 104 105 106 107 108 109 110 111 112 113 114 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/pump.rb', line 103 def self.pump(*args) if args[0].class.method_defined?(:j_del) && args[1].class.method_defined?(:j_del) && !block_given? && args[2] == nil return ::Vertx::Util::Utils.safe_create(Java::IoVertxCoreStreams::Pump.java_method(:pump, [Java::IoVertxCoreStreams::ReadStream.java_class,Java::IoVertxCoreStreams::WriteStream.java_class]).call(args[0].j_del,args[1].j_del),::Vertx::Pump) elsif args[0].class.method_defined?(:j_del) && args[1].class.method_defined?(:j_del) && args[2].class == Fixnum && !block_given? return ::Vertx::Util::Utils.safe_create(Java::IoVertxCoreStreams::Pump.java_method(:pump, [Java::IoVertxCoreStreams::ReadStream.java_class,Java::IoVertxCoreStreams::WriteStream.java_class,Java::int.java_class]).call(args[0].j_del,args[1].j_del,args[2]),::Vertx::Pump) end if defined?(super) super else raise ArgumentError, "Invalid arguments when calling pump(#{args[0]},#{args[1]},#{args[2]})" end end |
+ (Object) unwrap(obj)
43 44 45 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/pump.rb', line 43 def @@j_api_type.unwrap(obj) obj.j_del end |
+ (Object) wrap(obj)
40 41 42 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/pump.rb', line 40 def @@j_api_type.wrap(obj) Pump.new(obj) end |
Instance Method Details
- (Fixnum) numberPumped
69 70 71 72 73 74 75 76 77 78 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/pump.rb', line 69 def number_pumped if !block_given? return @j_del.java_method(:numberPumped, []).call() end if defined?(super) super else raise ArgumentError, "Invalid arguments when calling number_pumped()" end end |
- (self) setWriteQueueMaxSize(maxSize)
maxSize
119 120 121 122 123 124 125 126 127 128 129 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/pump.rb', line 119 def set_write_queue_max_size(*args) if args[0].class == Fixnum && !block_given? @j_del.java_method(:setWriteQueueMaxSize, [Java::int.java_class]).call(args[0]) return self end if defined?(super) super else raise ArgumentError, "Invalid arguments when calling set_write_queue_max_size(#{args[0]})" end end |
- (self) start
82 83 84 85 86 87 88 89 90 91 92 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/pump.rb', line 82 def start if !block_given? @j_del.java_method(:start, []).call() return self end if defined?(super) super else raise ArgumentError, "Invalid arguments when calling start()" end end |
- (self) stop
55 56 57 58 59 60 61 62 63 64 65 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/pump.rb', line 55 def stop if !block_given? @j_del.java_method(:stop, []).call() return self end if defined?(super) super else raise ArgumentError, "Invalid arguments when calling stop()" end end |