Class: Vertx::AsyncFile
- Inherits:
-
Object
- Object
- Vertx::AsyncFile
- Includes:
- ReadStream, WriteStream
- Defined in:
- src/main/api_shim/core/file_system.rb
Overview
Represents a file on the file-system which can be read from, or written to asynchronously.
The class also includes ReadStream and WriteStream - this allows the data to be pumped to and from
other streams, e.g. an HttpClientRequest instance, using the Pump class
Instance Method Summary (collapse)
-
- (Object) close(&block)
Close the file, asynchronously.
-
- (Object) flush
Flush any writes made to this file to underlying persistent storage, asynchronously.
-
- (Object) read_at_pos(buffer, offset, position, length, &block)
Reads some data from a file into a buffer, asynchronously.
-
- (Object) write_at_pos(buffer, position, &block)
Write a Buffer to the file, asynchronously.
Methods included from ReadStream
#data_handler, #end_handler, #exception_handler, #pause, #resume
Methods included from WriteStream
#drain_handler, #exception_handler, #write, #write_queue_full?, #write_queue_max_size, #write_queue_max_size=
Instance Method Details
- (Object) close(&block)
Close the file, asynchronously.
111 112 113 |
# File 'src/main/api_shim/core/file_system.rb', line 111 def close(&block) @j_del.close(ARWrappedHandler.new(block)) end |
- (Object) flush
Flush any writes made to this file to underlying persistent storage, asynchronously.
If the file was opened with flush set to true then calling this method will have no effect.
141 142 143 144 |
# File 'src/main/api_shim/core/file_system.rb', line 141 def flush Future.new(@j_del.flush) self end |
- (Object) read_at_pos(buffer, offset, position, length, &block)
Reads some data from a file into a buffer, asynchronously.
When multiple reads are invoked on the same file
there are no guarantees as to order in which those reads actually occur.
133 134 135 136 |
# File 'src/main/api_shim/core/file_system.rb', line 133 def read_at_pos(buffer, offset, position, length, &block) @j_del.read(buffer._to_java_buffer, offset, position, length, ARWrappedHandler.new(block) { |j_buff| Buffer.new(j_buff) }) self end |
- (Object) write_at_pos(buffer, position, &block)
Write a Buffer to the file, asynchronously.
When multiple writes are invoked on the same file
there are no guarantees as to order in which those writes actually occur.
starts with zero at the beginning of the file.
121 122 123 124 |
# File 'src/main/api_shim/core/file_system.rb', line 121 def write_at_pos(buffer, position, &block) @j_del.write(buffer._to_java_buffer, position, ARWrappedHandler.new(block)) self end |