Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions copa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,6 @@ impl<const OSC_RAW_BUF_SIZE: usize> Parser<OSC_RAW_BUF_SIZE> {
/// [`Perform::terminated`] is true after reading a byte.
///
/// Returns the number of bytes read before termination.
///
/// See [`Perform::advance`] for more details.
#[inline]
#[must_use = "Returned value should be used to processs the remaining bytes"]
pub fn advance_until_terminated<P: Perform>(
Expand Down
112 changes: 56 additions & 56 deletions corcovado/src/poll.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,52 @@
//! Poll is backed by two readiness queues. The first is a system readiness queue
//! represented by `sys::Selector`. The system readiness queue handles events
//! provided by the system, such as TCP and UDP. The second readiness queue is
//! implemented in user space by `ReadinessQueue`. It provides a way to implement
//! purely user space `Evented` types.
//!
//! `ReadinessQueue` is backed by a MPSC queue that supports reuse of linked
//! list nodes. This significantly reduces the number of required allocations.
//! Each `Registration` / `SetReadiness` pair allocates a single readiness node
//! that is used for the lifetime of the registration.
//!
//! The readiness node also includes a single atomic variable, `state` that
//! tracks most of the state associated with the registration. This includes the
//! current readiness, interest, poll options, and internal state. When the node
//! state is mutated, it is queued in the MPSC channel. A call to
//! `ReadinessQueue::poll` will dequeue and process nodes. The node state can
//! still be mutated while it is queued in the channel for processing.
//! Intermediate state values do not matter as long as the final state is
//! included in the call to `poll`. This is the eventually consistent nature of
//! the readiness queue.
//!
//! The readiness node is ref counted using the `ref_count` field. On creation,
//! the ref_count is initialized to 3: one `Registration` handle, one
//! `SetReadiness` handle, and one for the readiness queue. Since the readiness queue
//! doesn't *always* hold a handle to the node, we don't use the Arc type for
//! managing ref counts (this is to avoid constantly incrementing and
//! decrementing the ref count when pushing & popping from the queue). When the
//! `Registration` handle is dropped, the `dropped` flag is set on the node, then
//! the node is pushed into the registration queue. When Poll::poll pops the
//! node, it sees the drop flag is set, and decrements it's ref count.
//!
//! The MPSC queue is a modified version of the intrusive MPSC node based queue
//! described by 1024cores [1].
//!
//! The first modification is that two markers are used instead of a single
//! `stub`. The second marker is a `sleep_marker` which is used to signal to
//! producers that the consumer is going to sleep. This sleep_marker is only used
//! when the queue is empty, implying that the only node in the queue is
//! `end_marker`.
//!
//! The second modification is an `until` argument passed to the dequeue
//! function. When `poll` encounters a level-triggered node, the node will be
//! immediately pushed back into the queue. In order to avoid an infinite loop,
//! `poll` before pushing the node, the pointer is saved off and then passed
//! again as the `until` argument. If the next node to pop is `until`, then
//! `Dequeue::Empty` is returned.
//!
//! [1] <http://www.1024cores.net/home/lock-free-algorithms/queues/intrusive-mpsc-node-based-queue>

use event_imp::{self as event, Event, Evented, PollOpt, Ready};
use std::cell::UnsafeCell;
#[cfg(all(unix, not(target_os = "fuchsia")))]
Expand All @@ -14,55 +63,6 @@ use std::{fmt, io, ptr};
use std::{mem, ops};
use {sys, Token};

// Poll is backed by two readiness queues. The first is a system readiness queue
// represented by `sys::Selector`. The system readiness queue handles events
// provided by the system, such as TCP and UDP. The second readiness queue is
// implemented in user space by `ReadinessQueue`. It provides a way to implement
// purely user space `Evented` types.
//
// `ReadinessQueue` is backed by a MPSC queue that supports reuse of linked
// list nodes. This significantly reduces the number of required allocations.
// Each `Registration` / `SetReadiness` pair allocates a single readiness node
// that is used for the lifetime of the registration.
//
// The readiness node also includes a single atomic variable, `state` that
// tracks most of the state associated with the registration. This includes the
// current readiness, interest, poll options, and internal state. When the node
// state is mutated, it is queued in the MPSC channel. A call to
// `ReadinessQueue::poll` will dequeue and process nodes. The node state can
// still be mutated while it is queued in the channel for processing.
// Intermediate state values do not matter as long as the final state is
// included in the call to `poll`. This is the eventually consistent nature of
// the readiness queue.
//
// The readiness node is ref counted using the `ref_count` field. On creation,
// the ref_count is initialized to 3: one `Registration` handle, one
// `SetReadiness` handle, and one for the readiness queue. Since the readiness queue
// doesn't *always* hold a handle to the node, we don't use the Arc type for
// managing ref counts (this is to avoid constantly incrementing and
// decrementing the ref count when pushing & popping from the queue). When the
// `Registration` handle is dropped, the `dropped` flag is set on the node, then
// the node is pushed into the registration queue. When Poll::poll pops the
// node, it sees the drop flag is set, and decrements it's ref count.
//
// The MPSC queue is a modified version of the intrusive MPSC node based queue
// described by 1024cores [1].
//
// The first modification is that two markers are used instead of a single
// `stub`. The second marker is a `sleep_marker` which is used to signal to
// producers that the consumer is going to sleep. This sleep_marker is only used
// when the queue is empty, implying that the only node in the queue is
// `end_marker`.
//
// The second modification is an `until` argument passed to the dequeue
// function. When `poll` encounters a level-triggered node, the node will be
// immediately pushed back into the queue. In order to avoid an infinite loop,
// `poll` before pushing the node, the pointer is saved off and then passed
// again as the `until` argument. If the next node to pop is `until`, then
// `Dequeue::Empty` is returned.
//
// [1] http://www.1024cores.net/home/lock-free-algorithms/queues/intrusive-mpsc-node-based-queue

/// Polls for readiness events on all registered values.
///
/// `Poll` allows a program to monitor a large number of `Evented` types,
Expand Down Expand Up @@ -261,8 +261,8 @@ use {sys, Token};
/// Unless otherwise noted, it should be assumed that types implementing
/// [`Evented`] will never become ready unless they are registered with `Poll`.
///
/// For example:
///
// For example:
//
// ```
// # use std::error::Error;
// # fn try_main() -> Result<(), Box<dyn Error>> {
Expand Down Expand Up @@ -851,11 +851,11 @@ impl Poll {
// # try_main().unwrap();
// # }
// ```
//
// [`struct`]: #
// [`register`]: #method.register
// [`readable`]: struct.Ready.html#method.readable
// [`writable`]: struct.Ready.html#method.writable
///
/// [`struct`]: #
/// [`register`]: #method.register
/// [`readable`]: struct.Ready.html#method.readable
/// [`writable`]: struct.Ready.html#method.writable
pub fn reregister<E>(
&self,
handle: &E,
Expand Down
2 changes: 1 addition & 1 deletion corcovado/src/sys/windows/from_raw_arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//!
//! * The size of `FromRawArc` is actually two words because of the drop flag
//! * The compiler doesn't understand that the pointer in `FromRawArc` is never
//! null, so Option<FromRawArc<T>> is not a nullable pointer.
//! null, so `Option<FromRawArc<T>>` is not a nullable pointer.

use std::mem;
use std::ops::Deref;
Expand Down
2 changes: 1 addition & 1 deletion frontends/rioterm/src/hints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub struct HintState {
/// Visible matches for the current hint
matches: Vec<HintMatch>,

/// Labels for each match (as Vec<char>)
/// Labels for each match (as `Vec<char>`)
labels: Vec<Vec<char>>,

/// Keys pressed so far for hint selection
Expand Down
2 changes: 1 addition & 1 deletion frontends/rioterm/src/screen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ impl Screen<'_> {
}
}

/// Check whether we should try to build escape sequence for the [`KeyEvent`].
/// Check whether we should try to build escape sequence for the [`KeyEvent`](rio_window::event::KeyEvent).
fn should_build_sequence(
key: &rio_window::event::KeyEvent,
text: &str,
Expand Down
2 changes: 1 addition & 1 deletion rio-backend/src/ansi/mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ pub enum NamedPrivateMode {
UrgencyHints = 1042,
SwapScreenAndSetRestoreCursor = 1049,
BracketedPaste = 2004,
/// The mode is handled automatically by [`Processor`].
/// The mode is handled automatically by [`Processor`](crate::performer::handler::Processor).
SyncUpdate = 2026,
}

Expand Down
2 changes: 1 addition & 1 deletion rio-backend/src/config/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub struct Platform {

/// Other platform specific configuration options can be added here.
///
/// When deserializing, each field is Option<T> to distinguish between
/// When deserializing, each field is `Option<T>` to distinguish between
/// "not specified" vs "specified with value". During merge, we recursively
/// merge individual fields rather than replacing entire structures.
#[derive(Default, Debug, Serialize, Deserialize, PartialEq, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions rio-backend/src/crosswords/grid/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ impl<T> Storage<T> {
self.len == 0
}

/// Swap implementation for Row<T>.
/// Swap implementation for `Row<T>`.
///
/// Exploits the known size of Row<T> to produce a slightly more efficient
/// Exploits the known size of `Row<T>` to produce a slightly more efficient
/// swap than going through slice::swap.
///
/// The default implementation from swap generates 8 movups and 4 movaps
Expand Down
2 changes: 1 addition & 1 deletion rio-backend/src/crosswords/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ impl From<KeyboardModes> for Mode {
}
}

/// Terminal damage information collected since the last [`Term::reset_damage`] call.
/// Terminal damage information collected since the last [`Crosswords::reset_damage`] call.
#[derive(Debug)]
pub enum TermDamage<'a> {
/// The entire terminal is damaged.
Expand Down
12 changes: 6 additions & 6 deletions rio-backend/src/selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,17 @@ pub enum SelectionType {
/// Describes a region of a 2-dimensional area.
///
/// Used to track a text selection. There are four supported modes, each with its own constructor:
/// [`simple`], [`block`], [`semantic`], and [`lines`]. The [`simple`] mode precisely tracks which
/// [`simple`], [`block`], [`semantic`], and [`semantic`]. The [`simple`] mode precisely tracks which
/// cells are selected without any expansion. [`block`] will select rectangular regions.
/// [`lines`] will always select entire lines.
/// [`semantic`] will always select entire lines.
///
/// Calls to [`update`] operate different based on the selection kind. The [`simple`] and [`block`]
/// mode do nothing special, simply track points and sides.
///
/// [`simple`]: enum.Selection.html#method.simple
/// [`block`]: enum.Selection.html#method.block
/// [`lines`]: enum.Selection.html#method.rows
/// [`update`]: enum.Selection.html#method.update
/// [`simple`]: enum.SelectionType.html#variant.Simple
/// [`block`]: enum.SelectionType.html#variant.Block
/// [`semantic`]: enum.SelectionType.html#variant.Semantic
/// [`update`]: enum.SelectionType.html#variant.Update
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Selection {
pub ty: SelectionType,
Expand Down
2 changes: 1 addition & 1 deletion rio-window/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
//! [`Window`]: window::Window
//! [`WindowId`]: window::WindowId
//! [`WindowAttributes`]: window::WindowAttributes
//! [window_new]: window::Window::new
//! [window_new]: event_loop::ActiveEventLoop::create_window
//! [`create_window`]: event_loop::ActiveEventLoop::create_window
//! [`Window::id()`]: window::Window::id
//! [`WindowEvent`]: event::WindowEvent
Expand Down
6 changes: 3 additions & 3 deletions rio-window/src/platform/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,12 +454,12 @@ impl WindowExtWindows for Window {
pub trait WindowBorrowExtWindows: Borrow<Window> + Sized {
/// Create an object that allows accessing the inner window handle in a thread-unsafe way.
///
/// It is possible to call [`window_handle_any_thread`] to get around Windows's thread
/// It is possible to call [`window_handle_any_thread`](WindowExtWindows::window_handle_any_thread) to get around Windows's thread
/// affinity limitations. However, it may be desired to pass the [`Window`] into something
/// that requires the [`HasWindowHandle`] trait, while ignoring thread affinity limitations.
/// that requires the [`HasWindowHandle`](raw_window_handle::HasWindowHandle) trait, while ignoring thread affinity limitations.
///
/// This function wraps anything that implements `Borrow<Window>` into a structure that
/// uses the inner window handle as a mean of implementing [`HasWindowHandle`]. It wraps
/// uses the inner window handle as a mean of implementing [`HasWindowHandle`](raw_window_handle::HasWindowHandle). It wraps
/// `Window`, `&Window`, `Arc<Window>`, and other reference types.
///
/// # Safety
Expand Down
12 changes: 2 additions & 10 deletions sugarloaf/src/font_introspector/scale/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,7 @@ that yields [`NormalizedCoord`]s (a type alias for `i16` which is a fixed point
in 2.14 format). This method is faster than specifying variations by tag and value, but
the difference is likely negligible outside of microbenchmarks. The real advantage
is that a sequence of `i16` is more compact and easier to fold into a key in a glyph
cache. You can compute these normalized coordinates by using the
[`Variation::normalize`](crate::Variation::normalize) method for each available axis in
the font. The best strategy, however, is to simply capture these during shaping with
the [`Shaper::normalized_coords`](crate::shape::Shaper::normalized_coords) method which
will have already computed them for you.
cache.

See [`ScalerBuilder`] for available options and default values.

Expand Down Expand Up @@ -109,10 +105,6 @@ and [`scale_color_bitmap`](Scaler::scale_color_bitmap) for alpha and color bitma
respectively. These methods return an [`Image`] wrapped in an option. The associated
`_into` variants are also available.

Unlike outlines, bitmaps are available in [`strike`](crate::BitmapStrike)s of various sizes.
When requesting a bitmap, you specify the strategy for strike selection using the
[`StrikeWith`] enum.

For example, if we want the largest available unscaled image for the fire emoji:
```ignore
# use sugarloaf::font_introspector::{FontRef, CacheKey, scale::*};
Expand Down Expand Up @@ -807,7 +799,7 @@ impl<'a> Render<'a> {
}

/// Specifies the target format for rasterizing an outline. Default is
/// [`Format::Alpha`](zeno::Format::Alpha).
/// [`Format::Alpha`].
pub fn format(&mut self, format: Format) -> &mut Self {
self.format = format;
self
Expand Down
Loading