Ruby
3.4.0dev (2024-11-22 revision 80cfa57234255667a86d46096093099349a7262a)
|
#include "internal/dllexport.h"
#include "internal/fl_type.h"
#include "internal/special_consts.h"
#include "internal/stdbool.h"
#include "internal/value.h"
Go to the source code of this file.
Data Structures | |
struct | rb_ractor_local_storage_type |
Type that defines a ractor-local storage. More... | |
Macros | |
#define | RB_RACTOR_LOCAL_STORAGE_TYPE_FREE (&rb_ractor_local_storage_type_free) |
Just another name of rb_ractor_local_storage_type_free. More... | |
#define | RB_OBJ_SHAREABLE_P(obj) FL_TEST_RAW((obj), RUBY_FL_SHAREABLE) |
Queries if the passed object has previously classified as shareable or not. More... | |
Typedefs | |
typedef struct rb_ractor_local_key_struct * | rb_ractor_local_key_t |
(Opaque) struct that holds a ractor-local storage key. More... | |
Functions | |
VALUE | rb_ractor_stdin (void) |
Queries the standard input of the current Ractor that is calling this function. More... | |
VALUE | rb_ractor_stdout (void) |
Queries the standard output of the current Ractor that is calling this function. More... | |
VALUE | rb_ractor_stderr (void) |
Queries the standard error of the current Ractor that is calling this function. More... | |
void | rb_ractor_stdin_set (VALUE io) |
Assigns an IO to the standard input of the Ractor that is calling this function. More... | |
void | rb_ractor_stdout_set (VALUE io) |
Assigns an IO to the standard output of the Ractor that is calling this function. More... | |
void | rb_ractor_stderr_set (VALUE io) |
Assigns an IO to the standard error of the Ractor that is calling this function. More... | |
rb_ractor_local_key_t | rb_ractor_local_storage_value_newkey (void) |
Issues a new key. More... | |
VALUE | rb_ractor_local_storage_value (rb_ractor_local_key_t key) |
Queries the key. More... | |
bool | rb_ractor_local_storage_value_lookup (rb_ractor_local_key_t key, VALUE *val) |
Queries the key. More... | |
void | rb_ractor_local_storage_value_set (rb_ractor_local_key_t key, VALUE val) |
Associates the passed value to the passed key. More... | |
rb_ractor_local_key_t | rb_ractor_local_storage_ptr_newkey (const struct rb_ractor_local_storage_type *type) |
Extended version of rb_ractor_local_storage_value_newkey(). More... | |
void * | rb_ractor_local_storage_ptr (rb_ractor_local_key_t key) |
Identical to rb_ractor_local_storage_value() except the return type. More... | |
void | rb_ractor_local_storage_ptr_set (rb_ractor_local_key_t key, void *ptr) |
Identical to rb_ractor_local_storage_value_set() except the parameter type. More... | |
VALUE | rb_ractor_make_shareable (VALUE obj) |
Destructively transforms the passed object so that multiple Ractors can share it. More... | |
VALUE | rb_ractor_make_shareable_copy (VALUE obj) |
Identical to rb_ractor_make_shareable(), except it returns a (deep) copy of the passed one instead of modifying it in-place. More... | |
static bool | rb_ractor_shareable_p (VALUE obj) |
Queries if multiple Ractors can share the passed object or not. More... | |
Variables | |
VALUE | rb_cRactor |
Ractor class. More... | |
const struct rb_ractor_local_storage_type | rb_ractor_local_storage_type_free |
A type of ractor-local storage that destructs itself using ruby_xfree. More... | |
Definition in file ractor.h.
#define RB_OBJ_SHAREABLE_P | ( | obj | ) | FL_TEST_RAW((obj), RUBY_FL_SHAREABLE) |
Queries if the passed object has previously classified as shareable or not.
This doesn't mean anything in practice... Objects can be shared later. Always use rb_ractor_shareable_p() instead.
[in] | obj | Object in question. |
RUBY_FL_SHAREABLE | It once was shareable before. |
0 | Otherwise. |
#define RB_RACTOR_LOCAL_STORAGE_TYPE_FREE (&rb_ractor_local_storage_type_free) |
Just another name of rb_ractor_local_storage_type_free.
typedef struct rb_ractor_local_key_struct* rb_ractor_local_key_t |
void* rb_ractor_local_storage_ptr | ( | rb_ractor_local_key_t | key | ) |
Identical to rb_ractor_local_storage_value() except the return type.
[in] | key | A ractor-local storage key to lookup. |
NULL | No such key. |
otherwise | A value corresponds to key in the current Ractor. |
rb_ractor_local_key_t rb_ractor_local_storage_ptr_newkey | ( | const struct rb_ractor_local_storage_type * | type | ) |
Extended version of rb_ractor_local_storage_value_newkey().
It additionally takes the type of the issuing key.
[in] | type | How the value associated with the issuing key should behave. |
type
. Definition at line 3725 of file ractor.c.
Referenced by rb_ractor_local_storage_value_newkey().
void rb_ractor_local_storage_ptr_set | ( | rb_ractor_local_key_t | key, |
void * | ptr | ||
) |
Identical to rb_ractor_local_storage_value_set() except the parameter type.
[in] | key | A ractor-local storage key. |
[in] | ptr | A pointer that conforms key 's type. |
ptr
corresponds to key
in the current Ractor. VALUE rb_ractor_local_storage_value | ( | rb_ractor_local_key_t | key | ) |
Queries the key.
[in] | key | A ractor-local storage key to lookup. |
RUBY_Qnil | No such key. |
otherwise | A value corresponds to key in the current Ractor. |
bool rb_ractor_local_storage_value_lookup | ( | rb_ractor_local_key_t | key, |
VALUE * | val | ||
) |
rb_ractor_local_key_t rb_ractor_local_storage_value_newkey | ( | void | ) |
void rb_ractor_local_storage_value_set | ( | rb_ractor_local_key_t | key, |
VALUE | val | ||
) |
Destructively transforms the passed object so that multiple Ractors can share it.
What is a shareable object and what is not is a nuanced concept, and @ko1 says the definition can still change. However extension library authors might interest to learn how to use #RUBY_TYPED_FROZEN_SHAREABLE.
[out] | obj | Arbitrary ruby object to modify. |
rb_eRactorError | Ractors cannot share obj by nature. |
obj
. obj
. Definition at line 3078 of file ractor.c.
Referenced by rb_ractor_make_shareable_copy().
Identical to rb_ractor_make_shareable(), except it returns a (deep) copy of the passed one instead of modifying it in-place.
[in] | obj | Arbitrary ruby object to duplicate. |
rb_eRactorError | Ractors cannot share obj by nature. |
obj
which is sharable among Ractors.
|
inlinestatic |
Queries if multiple Ractors can share the passed object or not.
Ractors run without protecting each other. Sharing an object among them is basically dangerous, disabled by default. However there are objects that are extremely carefully implemented to be Ractor-safe; for instance integers have such property. This function can classify that.
[in] | obj | Arbitrary ruby object. |
true | obj is capable of shared across ractors. |
false | obj cannot travel across ractor boundaries. |
VALUE rb_ractor_stderr | ( | void | ) |
Queries the standard error of the current Ractor that is calling this function.
Definition at line 2724 of file ractor.c.
Referenced by rb_f_abort(), and rb_write_error2().
void rb_ractor_stderr_set | ( | VALUE | io | ) |
Assigns an IO to the standard error of the Ractor that is calling this function.
[in] | io | An IO. |
io
is the standard input of the current ractor. VALUE rb_ractor_stdin | ( | void | ) |
void rb_ractor_stdin_set | ( | VALUE | io | ) |
VALUE rb_ractor_stdout | ( | void | ) |
Queries the standard output of the current Ractor that is calling this function.
Definition at line 2712 of file ractor.c.
Referenced by rb_io_getbyte().
void rb_ractor_stdout_set | ( | VALUE | io | ) |
Assigns an IO to the standard output of the Ractor that is calling this function.
[in] | io | An IO. |
io
is the standard input of the current ractor.
|
extern |
A type of ractor-local storage that destructs itself using ruby_xfree.