8000 IO::Buffer improvements and documentation. by ioquatix · Pull Request #9329 · ruby/ruby · GitHub
[go: up one dir, main page]

Skip to content

IO::Buffer improvements and documentation. #9329

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Dec 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
cbf2dc1
Restore experimental warnings.
ioquatix Dec 23, 2023
a750ed0
Documentation and code structure improvements.
ioquatix Dec 23, 2023
a14f488
More documentation.
ioquatix Dec 23, 2023
dfffa4f
Avoid %z format specifier.
ioquatix Dec 23, 2023
bd5663a
Improved validation of flags, clarified documentation of argument han…
ioquatix Dec 23, 2023
a7fb502
Add documentation for constants.
ioquatix Dec 23, 2023
fc94ef9
Extended documentation around predicates and fixed private mappings.
ioquatix Dec 23, 2023
759b3c2
Improve documentation for transfer.
ioquatix Dec 24, 2023
dc053c5
Add documentation for hexdump and fix output string size computation.
ioquatix Dec 24, 2023
b82d359
Rather than raising an error, ignore unknown flags.
ioquatix Dec 24, 2023
ed03ab5
Remove inconsistent use of `Example:` and add example to `null?`.
ioquatix Dec 24, 2023
444a7d6
Add note about RUBY_IO_BUFFER_DEFAULT_SIZE.
ioquatix Dec 24, 2023
2e6ad3c
Add simple test for private mapped files.
ioquatix Dec 24, 2023
e4d92e6
Expose `private?`.
ioquatix Dec 24, 2023
d33a648
Add note about flags masking.
ioquatix Dec 24, 2023
2609786
Windows may require read/write file descriptor?
ioquatix Dec 24, 2023
2c93488
Let's hide this for now.
ioquatix Dec 24, 2023
2a0e24a
Use a real file for the test.
ioquatix Dec 24, 2023
9e198ec
Ensure the buffer is freed (unmapped) before unlinking the tempfile.
ioquatix Dec 24, 2023
1a64f08
Fix private mapping on Windows.
ioquatix Dec 24, 2023
da01d4b
Maybe this will work??? Windows please? 8000
ioquatix Dec 24, 2023
de1a324
Omit private mapped buffer test on Windows.
ioquatix Dec 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/ruby/fiber/scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ VALUE rb_fiber_scheduler_get(void);
* current thread will call scheduler's `#close` method on finalisation
* (allowing the scheduler to properly manage all non-finished fibers).
* `scheduler` can be an object of any class corresponding to
* `Fiber::SchedulerInterface`. Its implementation is up to the user.
* `Fiber::Scheduler` interface. Its implementation is up to the user.
*
* @param[in] scheduler The scheduler to set.
* @exception rb_eArgError `scheduler` does not conform the interface.
Expand Down
17 changes: 15 additions & 2 deletions include/ruby/io/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,18 @@ RBIMPL_SYMBOL_EXPORT_BEGIN()

#define RUBY_IO_BUFFER_VERSION 2

// The `IO::Buffer` class.
RUBY_EXTERN VALUE rb_cIOBuffer;

// The operating system page size.
RUBY_EXTERN size_t RUBY_IO_BUFFER_PAGE_SIZE;

// The default buffer size, usually a (small) multiple of the page size.
// Can be overridden by the RUBY_IO_BUFFER_DEFAULT_SIZE environment variable.
RUBY_EXTERN size_t RUBY_IO_BUFFER_DEFAULT_SIZE;

// Represents the internal state of the buffer.
// More than one flag can be set at a time.
enum rb_io_buffer_flags {
// The memory in the buffer is owned by someone else.
// More specifically, it means that someone else owns the buffer and we shouldn't try to resize it.
Expand All @@ -49,10 +57,12 @@ enum rb_io_buffer_flags {
RB_IO_BUFFER_PRIVATE = 64,

// The buffer is read-only and cannot be modified.
RB_IO_BUFFER_READONLY = 128
RB_IO_BUFFER_READONLY = 128,
};

// Represents the endian of the data types.
enum rb_io_buffer_endian {
// The least significant units are put first.
RB_IO_BUFFER_LITTLE_ENDIAN = 4,
RB_IO_BUFFER_BIG_ENDIAN = 8,

Expand All @@ -79,7 +89,10 @@ int rb_io_buffer_try_unlock(VALUE self);
VALUE rb_io_buffer_free(VALUE self);
VALUE rb_io_buffer_free_locked(VALUE self);

int rb_io_buffer_get_bytes(VALUE self, void **base, size_t *size);
// Access the internal buffer and flags. Validates the pointers.
// The points may not remain valid if the source buffer is manipulated.
// Consider using rb_io_buffer_lock if needed.
enum rb_io_buffer_flags rb_io_buffer_get_bytes(VALUE self, void **base, size_t *size);
void rb_io_buffer_get_bytes_for_reading(VALUE self, const void **base, size_t *size);
void rb_io_buffer_get_bytes_for_writing(VALUE self, void **base, size_t *size);

Expand Down
Loading
0