|
Ruby 4.0.5p0 (2026-05-20 revision 64336ffd0ee9e1f4c05891695a3d7b49cb709721)
|
Public APIs to provide rb_fd_select(). More...
#include "ruby/internal/config.h"#include "ruby/internal/dllexport.h"#include "ruby/internal/intern/select/posix.h"Go to the source code of this file.
Macros | |
| #define | rb_fd_resize(n, f) |
| Does nothing (defined for compatibility). | |
Functions | |
| int | rb_thread_fd_select (int nfds, rb_fdset_t *rfds, rb_fdset_t *wfds, rb_fdset_t *efds, struct timeval *timeout) |
| Waits for multiple file descriptors at once. | |
Public APIs to provide rb_fd_select().
Definition in file select.h.
| #define rb_fd_resize | ( | n, | |
| f ) |
| int rb_thread_fd_select | ( | int | nfds, |
| rb_fdset_t * | rfds, | ||
| rb_fdset_t * | wfds, | ||
| rb_fdset_t * | efds, | ||
| struct timeval * | timeout ) |
Waits for multiple file descriptors at once.
This is basically a wrapper of system-provided select() with releasing GVL, to allow other Ruby threads run in parallel.
| [in] | nfds | Max FD in everything passed, plus one. |
| [in,out] | rfds | Set of FDs to wait for reads. |
| [in,out] | wfds | Set of FDs to wait for writes. |
| [in,out] | efds | Set of FDs to wait for OOBs. |
| [in,out] | timeout | Max blocking duration. |
| -1 | Failed, errno set. |
| 0 | Timeout exceeded. |
| otherwise | Total number of file descriptors returned. |
Although backend threads can run in parallel of this function, touching a file descriptor from multiple threads could be problematic. For instance what happens when a thread closes a file descriptor that is selected by someone else, vastly varies among operating systems. You would better avoid touching an fd from more than one threads.
NOTE: this function is used in native extensions, so change its API with care.
Definition at line 4546 of file thread.c.
Referenced by rb_thread_fd_select().