module Crystal::EventLoop::FileDescriptor

Direct including types

Defined in:

crystal/event_loop/file_descriptor.cr

Instance Method Summary

Instance Method Detail

abstract def close(file_descriptor : Crystal::System::FileDescriptor) : Nil #

Closes the file descriptor resource.


[View source]
abstract def open(path : String, flags : Int32, permissions : File::Permissions, blocking : Bool | Nil) : Tuple(System::FileDescriptor::Handle, Bool) | Errno | WinError #

Opens a file at path.

Blocks the current fiber until the file has been opened. Avoids blocking the current thread if possible, especially when blocking is false or nil.

Returns the system file descriptor or handle, or a system error.


[View source]
abstract def pipe(read_blocking : Bool | Nil, write_blocking : Bool | Nil) : Tuple(IO::FileDescriptor, IO::FileDescriptor) #

Opens an unidirectional pipe.

The implementation shall respect the specified blocking arguments for each end of the pipe, and follow its internal blocking requirements when a blocking arg is nil.

Returns a tuple with the reader and writer IO objects.


[View source]
abstract def read(file_descriptor : Crystal::System::FileDescriptor, slice : Bytes) : Int32 #

Reads at least one byte from the file descriptor into slice.

Blocks the current fiber if no data is available for reading, continuing when available. Otherwise returns immediately.

Returns the number of bytes read (up to slice.size). Returns 0 when EOF is reached.


[View source]
abstract def reopened(file_descriptor : Crystal::System::FileDescriptor) : Nil #

Hook to react on the file descriptor after it has been reopened. For example we might want to resume all pending operations to act on the new file descriptor.


[View source]
abstract def wait_readable(file_descriptor : Crystal::System::FileDescriptor) : Nil #

Blocks the current fiber until the file descriptor is ready for read.


[View source]
abstract def wait_writable(file_descriptor : Crystal::System::FileDescriptor) : Nil #

Blocks the current fiber until the file descriptor is ready for write.


[View source]
abstract def write(file_descriptor : Crystal::System::FileDescriptor, slice : Bytes) : Int32 #

Writes at least one byte from slice to the file descriptor.

Blocks the current fiber if the file descriptor isn't ready for writing, continuing when ready. Otherwise returns immediately.

Returns the number of bytes written (up to slice.size).


[View source]