summaryrefslogtreecommitdiff
path: root/internal/io.h
diff options
context:
space:
mode:
Diffstat (limited to 'internal/io.h')
-rw-r--r--internal/io.h26
1 files changed, 25 insertions, 1 deletions
diff --git a/internal/io.h b/internal/io.h
index 0fcb72ffab..2110f0b087 100644
--- a/internal/io.h
+++ b/internal/io.h
@@ -14,10 +14,21 @@
struct rb_io;
#include "ruby/io.h" /* for rb_io_t */
+#include "ccan/list/list.h"
+#include "serial.h"
#define IO_WITHOUT_GVL(func, arg) rb_nogvl(func, arg, RUBY_UBF_IO, 0, RB_NOGVL_OFFLOAD_SAFE)
#define IO_WITHOUT_GVL_INT(func, arg) (int)(VALUE)IO_WITHOUT_GVL(func, arg)
+// Represents an in-flight blocking operation:
+struct rb_io_blocking_operation {
+ // The linked list data structure.
+ struct ccan_list_node list;
+
+ // The execution context of the blocking operation.
+ struct rb_execution_context_struct *ec;
+};
+
/** Ruby's IO, metadata and buffers. */
struct rb_io {
@@ -111,6 +122,18 @@ struct rb_io {
* The timeout associated with this IO when performing blocking operations.
*/
VALUE timeout;
+
+ /**
+ * Threads that are performing a blocking operation without the GVL using
+ * this IO. On calling IO#close, these threads will be interrupted so that
+ * the operation can be cancelled.
+ */
+ struct ccan_list_head blocking_operations;
+ struct rb_execution_context_struct *closing_ec;
+ VALUE wakeup_mutex;
+
+ // The fork generation of the blocking operations list.
+ rb_serial_t fork_generation;
};
/* io.c */
@@ -125,7 +148,8 @@ VALUE rb_io_prep_stdin(void);
VALUE rb_io_prep_stdout(void);
VALUE rb_io_prep_stderr(void);
-int rb_io_fptr_finalize(struct rb_io *fptr);
+int rb_io_notify_close(struct rb_io *fptr);
+bool rb_io_fptr_finalize_closed(struct rb_io *fptr);
RUBY_SYMBOL_EXPORT_BEGIN
/* io.c (export) */