Files
Luke Gruber 7ba699ae26 Make fibers RUBY_TYPED_THREAD_SAFE_FREE
Now fibers can be collected by multiple ractors at once when those Ractors
are running local GCs. Fibers are created in the Ractor that owns them, so
if multiple Ractors have unmarked fibers during local GC sweeping, we can
now collect them concurrently instead of deferring their collection to a
postponed job. Each fiber pool is protected by its own native mutex.

In the future, maybe fiber pools will be ractor-local, but we have to
experiment with it first and see if it's enough of a performance win to
justify the change. We also want to minimize resource acquisition for each
Ractor as they're supposed to be lighweight.
2026-09-22 09:48:07 -04:00

34 lines
1.4 KiB
C

#ifndef INTERNAL_CONT_H /*-*-C-*-vi:se ft=c:*/
#define INTERNAL_CONT_H
/**
* @author Ruby developers <ruby-core@ruby-lang.org>
* @copyright This file is a part of the programming language Ruby.
* Permission is hereby granted, to either redistribute and/or
* modify this file, provided that the conditions mentioned in the
* file COPYING are met. Consult the file for details.
* @brief Internal header for Fiber.
*/
#include "ruby/ruby.h" /* for VALUE */
struct rb_thread_struct; /* in vm_core.h */
struct rb_fiber_struct; /* in cont.c */
struct rb_execution_context_struct; /* in vm_core.c */
/* cont.c */
void rb_fiber_reset_root_local_storage(struct rb_thread_struct *);
void ruby_register_rollback_func_for_ensure(VALUE (*ensure_func)(VALUE), VALUE (*rollback_func)(VALUE));
/* vm.c */
void rb_free_shared_fiber_pool(void);
/* thread.c */
void rb_fiber_pool_lock_atfork(void);
// Copy locals from the current execution to the specified fiber.
VALUE rb_fiber_inherit_storage(struct rb_execution_context_struct *ec, struct rb_fiber_struct *fiber);
VALUE rb_fiberptr_self(struct rb_fiber_struct *fiber);
unsigned int rb_fiberptr_blocking(struct rb_fiber_struct *fiber);
struct rb_execution_context_struct * rb_fiberptr_get_ec(struct rb_fiber_struct *fiber);
void rb_fiber_free_body(void *fiber); /* cont.c */
#endif /* INTERNAL_CONT_H */