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

doc: Improve directory::Lock docs. #1534

Merged
merged 1 commit into from
Sep 20, 2022
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
2 changes: 1 addition & 1 deletion src/directory/directory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ pub trait Directory: DirectoryClone + fmt::Debug + Send + Sync + 'static {
/// effectively stored durably.
fn sync_directory(&self) -> io::Result<()>;

/// Acquire a lock in the given directory.
/// Acquire a lock in the directory given in the [`Lock`].
///
/// The method is blocking or not depending on the [`Lock`] object.
fn acquire_lock(&self, lock: &Lock) -> Result<DirectoryLock, LockError> {
Expand Down
11 changes: 7 additions & 4 deletions src/directory/directory_lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ use once_cell::sync::Lazy;

/// A directory lock.
///
/// A lock is associated to a specific path and some
/// [`LockParams`](./enum.LockParams.html).
/// A lock is associated with a specific path.
///
/// The lock will be passed to [`Directory::acquire_lock`](crate::Directory::acquire_lock).
///
/// Tantivy itself uses only two locks but client application
/// can use the directory facility to define their own locks.
/// - [`INDEX_WRITER_LOCK`]
Expand All @@ -18,12 +20,13 @@ pub struct Lock {
/// Depending on the platform, the lock might rely on the creation
/// and deletion of this filepath.
pub filepath: PathBuf,
/// `lock_params` describes whether acquiring the lock is meant
/// `is_blocking` describes whether acquiring the lock is meant
/// to be a blocking operation or a non-blocking.
///
/// Acquiring a blocking lock blocks until the lock is
/// available.
/// Acquiring a blocking lock returns rapidly, either successfully
///
/// Acquiring a non-blocking lock returns rapidly, either successfully
/// or with an error signifying that someone is already holding
/// the lock.
pub is_blocking: bool,
Expand Down
4 changes: 3 additions & 1 deletion src/directory/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ use std::{fmt, io};

use crate::Version;

/// Error while trying to acquire a directory lock.
/// Error while trying to acquire a directory [lock](crate::directory::Lock).
///
/// This is returned from [`Directory::acquire_lock`](crate::Directory::acquire_lock).
#[derive(Debug, Clone, Error)]
pub enum LockError {
/// Failed to acquired a lock as it is already held by another
Expand Down