Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate doc link to intra-doc-link, fix broken links #310

Merged
merged 1 commit into from
Mar 2, 2021
Merged
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
6 changes: 4 additions & 2 deletions src/bastion-executor/src/blocking.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
//!
//! Pool of threads to run heavy processes
//!
//! We spawn futures onto the pool with [spawn_blocking] method of global run queue or
//! with corresponding [Worker]'s spawn method.
//! We spawn futures onto the pool with [`spawn_blocking`] method of global run queue or
//! with corresponding [`Worker`]'s spawn method.
//!
//! [`Worker`]: crate::run_queue::Worker

use crate::thread_manager::{DynamicPoolManager, DynamicRunner};
use crossbeam_channel::{unbounded, Receiver, Sender};
Expand Down
7 changes: 5 additions & 2 deletions src/bastion-executor/src/pool.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
//!
//! Pool of threads to run lightweight processes
//!
//! We spawn futures onto the pool with [spawn] method of global run queue or
//! with corresponding [Worker]'s spawn method.
//! We spawn futures onto the pool with [`spawn`] method of global run queue or
//! with corresponding [`Worker`]'s spawn method.
//!
//! [`spawn`]: crate::pool::spawn
//! [`Worker`]: crate::run_queue::Worker

use crate::thread_manager::{DynamicPoolManager, DynamicRunner};
use crate::worker;
Expand Down
39 changes: 19 additions & 20 deletions src/bastion-executor/src/run_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,34 @@
//!
//! [`Worker`] has two constructors:
//!
//! * [`new_fifo()`] - Creates a FIFO queue, in which tasks are pushed and popped from opposite
//! * [`new_fifo`] - Creates a FIFO queue, in which tasks are pushed and popped from opposite
//! ends.
//! * [`new_lifo()`] - Creates a LIFO queue, in which tasks are pushed and popped from the same
//! * [`new_lifo`] - Creates a LIFO queue, in which tasks are pushed and popped from the same
//! end.
//!
//! Each [`Worker`] is owned by a single thread and supports only push and pop operations.
//!
//! Method [`stealer()`] creates a [`Stealer`] that may be shared among threads and can only steal
//! Method [`stealer`] creates a [`Stealer`] that may be shared among threads and can only steal
//! tasks from its [`Worker`]. Tasks are stolen from the end opposite to where they get pushed.
//!
//! # Stealing
//!
//! Steal operations come in three flavors:
//!
//! 1. [`steal()`] - Steals one task.
//! 2. [`steal_batch()`] - Steals a batch of tasks and moves them into another worker.
//! 3. [`steal_batch_and_pop()`] - Steals a batch of tasks, moves them into another queue, and pops
//! 1. [`steal`] - Steals one task.
//! 2. [`steal_batch`] - Steals a batch of tasks and moves them into another worker.
//! 3. [`steal_batch_and_pop`] - Steals a batch of tasks, moves them into another queue, and pops
//! one task from that worker.
//!
//! In contrast to push and pop operations, stealing can spuriously fail with [`Steal::Retry`], in
//! which case the steal operation needs to be retried.
//!
//!
//! [`Worker`]: struct.Worker.html
//! [`Stealer`]: struct.Stealer.html
//! [`Injector`]: struct.Injector.html
//! [`Steal::Retry`]: enum.Steal.html#variant.Retry
//! [`new_fifo()`]: struct.Worker.html#method.new_fifo
//! [`new_lifo()`]: struct.Worker.html#method.new_lifo
//! [`stealer()`]: struct.Worker.html#method.stealer
//! [`steal()`]: struct.Stealer.html#method.steal
//! [`steal_batch()`]: struct.Stealer.html#method.steal_batch
//! [`steal_batch_and_pop()`]: struct.Stealer.html#method.steal_batch_and_pop
//! [`new_fifo`]: Worker::new_fifo
//! [`new_lifo`]: Worker::new_lifo
//! [`stealer`]: Worker::stealer
//! [`steal`]: Stealer::steal
//! [`steal_batch`]: Stealer::steal_batch
//! [`steal_batch_and_pop`]: Stealer::steal_batch_and_pop
use crossbeam_epoch::{self as epoch, Atomic, Owned};
use crossbeam_utils::{Backoff, CachePadded};
use std::cell::{Cell, UnsafeCell};
Expand Down Expand Up @@ -1784,10 +1779,14 @@ impl<T> fmt::Debug for Steal<T> {
}

impl<T> FromIterator<Steal<T>> for Steal<T> {
/// Consumes items until a `Success` is found and returns it.
/// Consumes items until a [`Success`] is found and returns it.
///
/// If no [`Success`] was found, but there was at least one [`Retry`], then returns [`Retry`].
/// Otherwise, [`Empty`] is returned.
///
/// If no `Success` was found, but there was at least one `Retry`, then returns `Retry`.
/// Otherwise, `Empty` is returned.
/// [`Success`]: Steal::Success
/// [`Retry`]: Steal::Retry
/// [`Empty`]: Steal::Empty
fn from_iter<I>(iter: I) -> Steal<T>
where
I: IntoIterator<Item = Steal<T>>,
Expand Down
22 changes: 1 addition & 21 deletions src/bastion/src/bastion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,6 @@ impl Bastion {
/// # Bastion::block_until_stopped();
/// # }
/// ```
///
/// [`Config`]: struct.Config.html
/// [`Bastion::init_with`]: #method.init_with
pub fn init() {
let config = Config::default();
Bastion::init_with(config)
Expand Down Expand Up @@ -254,9 +251,6 @@ impl Bastion {
/// # Bastion::block_until_stopped();
/// # }
/// ```
///
/// [`Config`]: struct.Config.html
/// [`Bastion::init`]: #method.init
pub fn init_with(config: Config) {
debug!("Bastion: Initializing with config: {:?}", config);
if config.backtraces().is_hide() {
Expand Down Expand Up @@ -310,9 +304,6 @@ impl Bastion {
/// # Bastion::block_until_stopped();
/// # }
/// ```
///
/// [`Supervisor`]: supervisor/struct.Supervisor.html
/// [`SupervisorRef`]: supervisor/struct.SupervisorRef.html
pub fn supervisor<S>(init: S) -> Result<SupervisorRef, ()>
where
S: FnOnce(Supervisor) -> Supervisor,
Expand Down Expand Up @@ -392,9 +383,6 @@ impl Bastion {
/// # Bastion::block_until_stopped();
/// # }
/// ```
///
/// [`Children`]: children/struct.Children.html
/// [`ChildrenRef`]: children/struct.ChildrenRef.html
pub fn children<C>(init: C) -> Result<ChildrenRef, ()>
where
C: FnOnce(Children) -> Children,
Expand Down Expand Up @@ -446,11 +434,6 @@ impl Bastion {
/// # Bastion::block_until_stopped();
/// # }
/// ```
///
/// [`Children::with_exec`]: children/struct.Children.html#method.with_exec
/// [`Bastion::children`]: #method.children
/// [`Children`]: children/struct.Children.html
/// [`ChildrenRef`]: children/struct.ChildrenRef.html
pub fn spawn<I, F>(action: I) -> Result<ChildrenRef, ()>
where
I: Fn(BastionContext) -> F + Send + 'static,
Expand Down Expand Up @@ -674,7 +657,7 @@ impl Bastion {
}

/// Blocks the current thread until the system is stopped
/// (either by calling [`Bastion::stop()`] or
/// (either by calling [`Bastion::stop`] or
/// [`Bastion::kill`]).
///
/// # Example
Expand Down Expand Up @@ -708,9 +691,6 @@ impl Bastion {
/// // stopped or killed it...
/// # }
/// ```
///
/// [`Bastion::stop()`]: #method.stop
/// [`Bastion::kill()`]: #method.kill
pub fn block_until_stopped() {
debug!("Bastion: Blocking until system is stopped.");
SYSTEM.wait_until_stopped();
Expand Down
40 changes: 20 additions & 20 deletions src/bastion/src/callbacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ pub(crate) enum CallbackType {
/// # }
/// ```
///
/// [`Supervisor`]: supervisor/struct.Supervisor.html
/// [`Children`]: children/struct.Children.html
/// [`Supervisor`]: crate::supervisor::Supervisor
/// [`Children`]: crate::children::Children
pub struct Callbacks {
before_start: Option<Arc<dyn Fn() + Send + Sync>>,
before_restart: Option<Arc<dyn Fn() + Send + Sync>>,
Expand Down Expand Up @@ -111,8 +111,8 @@ impl Callbacks {
/// # }
/// ```
///
/// [`Supervisor::with_callbacks`]: supervisor/struct.Supervisor.html#method.with_callbacks
/// [`Children::with_callbacks`]: children/struct.Children.html#method.with_callbacks
/// [`Supervisor::with_callbacks`]: crate::supervisor::Supervisor::with_callbacks
/// [`Children::with_callbacks`]: crate::children::Children::with_callbacks
pub fn new() -> Self {
Callbacks::default()
}
Expand Down Expand Up @@ -179,9 +179,9 @@ impl Callbacks {
/// # }
/// ```
///
/// [`Supervisor`]: supervisor/struct.Supervisor.html
/// [`Children`]: children/struct.Children.html
/// [`with_after_restart`]: #method.with_after_start
/// [`Supervisor`]: crate::supervisor::Supervisor
/// [`Children`]: crate::children::Children
/// [`with_after_restart`]: Self::with_after_restart
pub fn with_before_start<C>(mut self, before_start: C) -> Self
where
C: Fn() + Send + Sync + 'static,
Expand Down Expand Up @@ -253,9 +253,9 @@ impl Callbacks {
/// # }
/// ```
///
/// [`Supervisor`]: supervisor/struct.Supervisor.html
/// [`Children`]: children/struct.Children.html
/// [`with_after_stop`]: #method.with_after_stop
/// [`Supervisor`]: crate::supervisor::Supervisor
/// [`Children`]: crate::children::Children
/// [`with_after_stop`]: Self::with_after_stop
pub fn with_before_restart<C>(mut self, before_restart: C) -> Self
where
C: Fn() + Send + Sync + 'static,
Expand Down Expand Up @@ -327,9 +327,9 @@ impl Callbacks {
/// # }
/// ```
///
/// [`Supervisor`]: supervisor/struct.Supervisor.html
/// [`Children`]: children/struct.Children.html
/// [`with_before_start`]: #method.with_before_start
/// [`Supervisor`]: crate::supervisor::Supervisor
/// [`Children`]: crate::children::Children
/// [`with_before_start`]: Self::method.with_before_start
pub fn with_after_restart<C>(mut self, after_restart: C) -> Self
where
C: Fn() + Send + Sync + 'static,
Expand Down Expand Up @@ -403,9 +403,9 @@ impl Callbacks {
/// # }
/// ```
///
/// [`Supervisor`]: supervisor/struct.Supervisor.html
/// [`Children`]: children/struct.Children.html
/// [`with_before_restart`]: #method.with_before_restart
/// [`Supervisor`]: crate::supervisor::Supervisor
/// [`Children`]: crate::children::Children
/// [`with_before_restart`]: Self::with_before_restart
pub fn with_after_stop<C>(mut self, after_stop: C) -> Self
where
C: Fn() + Send + Sync + 'static,
Expand All @@ -428,7 +428,7 @@ impl Callbacks {
/// assert!(callbacks.has_before_start());
/// ```
///
/// [`with_before_start`]: #method.with_before_start
/// [`with_before_start`]: Self::with_before_start
pub fn has_before_start(&self) -> bool {
self.before_start.is_some()
}
Expand All @@ -446,7 +446,7 @@ impl Callbacks {
/// assert!(callbacks.has_before_restart());
/// ```
///
/// [`with_before_restart`]: #method.with_before_restart
/// [`with_before_restart`]: Self::with_before_restart
pub fn has_before_restart(&self) -> bool {
self.before_restart.is_some()
}
Expand All @@ -464,7 +464,7 @@ impl Callbacks {
/// assert!(callbacks.has_after_restart());
/// ```
///
/// [`with_after_restart`]: #method.with_after_restart
/// [`with_after_restart`]: Self::with_after_restart
pub fn has_after_restart(&self) -> bool {
self.after_restart.is_some()
}
Expand All @@ -482,7 +482,7 @@ impl Callbacks {
/// assert!(callbacks.has_after_stop());
/// ```
///
/// [`with_after_stop`]: #method.with_after_stop
/// [`with_after_stop`]: Self::with_after_stop
pub fn has_after_stop(&self) -> bool {
self.after_stop.is_some()
}
Expand Down
3 changes: 1 addition & 2 deletions src/bastion/src/child_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ impl ChildRef {
/// # }
/// ```
///
/// [`Answer`]: message/struct.Answer.html
pub fn ask_anonymously<M: Message>(&self, msg: M) -> Result<Answer, M> {
debug!("ChildRef({}): Asking message: {:?}", self.id(), msg);
let (msg, answer) = BastionMessage::ask(msg);
Expand Down Expand Up @@ -435,7 +434,7 @@ impl ChildRef {
&self.path
}

/// Return the [`name`] of the child
/// Return the `name` of the child
pub fn name(&self) -> &str {
&self.name
}
Expand Down
14 changes: 5 additions & 9 deletions src/bastion/src/children.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ use tracing::{debug, trace, warn};
/// # }
/// ```
///
/// [`with_redundancy`]: #method.with_redundancy
/// [`with_exec`]: #method.with_exec
/// [`SupervisionStrategy`]: supervisor/enum.SupervisionStrategy.html
/// [`with_redundancy`]: Self::with_redundancy
/// [`with_exec`]: Self::with_exec
/// [`SupervisionStrategy`]: crate::supervisor::SupervisionStrategy
pub struct Children {
bcast: Broadcast,
// The currently launched elements of the group.
Expand Down Expand Up @@ -354,7 +354,7 @@ impl Children {
/// # }
/// ```
///
/// [`with_exec`]: #method.with_exec
/// [`with_exec`]: Self::with_exec
pub fn with_redundancy(mut self, redundancy: usize) -> Self {
trace!(
"Children({}): Setting redundancy: {}",
Expand Down Expand Up @@ -414,7 +414,7 @@ impl Children {
/// # Bastion::block_until_stopped();
/// # }
/// ```
/// [`DispatcherHandler`]: ../dispatcher/trait.DispatcherHandler.html
/// [`DispatcherHandler`]: crate::dispatcher::DispatcherHandler
pub fn with_dispatcher(mut self, dispatcher: Dispatcher) -> Self {
self.dispatchers.push(Arc::new(Box::new(dispatcher)));
self
Expand Down Expand Up @@ -462,7 +462,6 @@ impl Children {
/// # Bastion::block_until_stopped();
/// # }
/// ```
/// [`Resizer`]: ../resizer/struct.Resizer.html
pub fn with_resizer(mut self, mut resizer: OptimalSizeExploringResizer) -> Self {
self.redundancy = resizer.lower_bound() as usize;
self.resizer = Box::new(resizer);
Expand Down Expand Up @@ -521,8 +520,6 @@ impl Children {
/// # Bastion::block_until_stopped();
/// # }
/// ```
///
/// [`Callbacks`]: struct.Callbacks.html
pub fn with_callbacks(mut self, callbacks: Callbacks) -> Self {
trace!(
"Children({}): Setting callbacks: {:?}",
Expand Down Expand Up @@ -579,7 +576,6 @@ impl Children {
/// # Bastion::block_until_stopped();
/// # }
/// ```
/// [`std::time::Duration`]: https://doc.rust-lang.org/nightly/core/time/struct.Duration.html
pub fn with_heartbeat_tick(mut self, interval: Duration) -> Self {
trace!(
"Children({}): Set heartbeat tick to {:?}",
Expand Down
6 changes: 1 addition & 5 deletions src/bastion/src/children_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ impl ChildrenRef {
/// # Bastion::block_until_stopped();
/// # }
/// ```
///
/// [`ChildRef`]: children/struct.ChildRef.html
pub fn dispatchers(&self) -> &Vec<DispatcherType> {
&self.dispatchers
}
Expand Down Expand Up @@ -148,8 +146,6 @@ impl ChildrenRef {
/// # Bastion::block_until_stopped();
/// # }
/// ```
///
/// [`ChildRef`]: children/struct.ChildRef.html
pub fn elems(&self) -> &[ChildRef] {
&self.children
}
Expand Down Expand Up @@ -216,7 +212,7 @@ impl ChildrenRef {
/// # }
/// ```
///
/// [`elems`]: #method.elems
/// [`elems`]: Self::elems
pub fn broadcast<M: Message>(&self, msg: M) -> Result<(), M> {
debug!(
"ChildrenRef({}): Broadcasting message: {:?}",
Expand Down
Loading