Skip to content

Commit

Permalink
squash!: rename xor to exclusive
Browse files Browse the repository at this point in the history
Signed-off-by: bsbds <[email protected]>
  • Loading branch information
bsbds committed Apr 19, 2024
1 parent 58f9f15 commit 6e0a111
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion crates/xline/src/conflict/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ where
}

/// Returns `true` if this command conflicts with all other commands
fn is_xor_cmd(cmd: &Command) -> bool {
fn is_exclusive_cmd(cmd: &Command) -> bool {
matches!(
*cmd.request(),
RequestWrapper::CompactionRequest(_)
Expand Down
12 changes: 6 additions & 6 deletions crates/xline/src/conflict/spec_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use xlineapi::{
interval::BytesAffine,
};

use super::{filter_kv, intervals, is_xor_cmd};
use super::{filter_kv, intervals, is_exclusive_cmd};

/// Speculative pool for KV commands.
#[derive(Debug, Default)]
Expand Down Expand Up @@ -113,20 +113,20 @@ impl SpeculativePoolOp for LeaseSpecPool {

/// Speculative pool for commands that conflict with all other commands.
#[derive(Debug, Default)]
pub(crate) struct XorSpecPool {
pub(crate) struct ExclusiveSpecPool {
/// Stores the command
conflict: Option<CommandEntry<Command>>,
}

impl ConflictPoolOp for XorSpecPool {
impl ConflictPoolOp for ExclusiveSpecPool {
type Entry = CommandEntry<Command>;

fn is_empty(&self) -> bool {
self.conflict.is_none()
}

fn remove(&mut self, entry: Self::Entry) {
if is_xor_cmd(&entry) {
if is_exclusive_cmd(&entry) {
self.conflict = None;
}
}
Expand All @@ -144,13 +144,13 @@ impl ConflictPoolOp for XorSpecPool {
}
}

impl SpeculativePoolOp for XorSpecPool {
impl SpeculativePoolOp for ExclusiveSpecPool {
fn insert_if_not_conflict(&mut self, entry: Self::Entry) -> Option<Self::Entry> {
if self.conflict.is_some() {
return Some(entry);
}

if is_xor_cmd(&entry) {
if is_exclusive_cmd(&entry) {
self.conflict = Some(entry.clone());
// Always returns conflict when the command conflicts with all other commands
return Some(entry);
Expand Down
12 changes: 6 additions & 6 deletions crates/xline/src/conflict/uncommitted_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use xlineapi::{
interval::BytesAffine,
};

use super::{filter_kv, intervals, is_xor_cmd};
use super::{filter_kv, intervals, is_exclusive_cmd};

/// Uncommitted pool for KV commands.
#[derive(Debug, Default)]
Expand Down Expand Up @@ -158,12 +158,12 @@ impl UncommittedPoolOp for LeaseUncomPool {

/// Uncommitted pool for commands that conflict with all other commands.
#[derive(Debug, Default)]
pub(crate) struct XorUncomPool {
pub(crate) struct ExclusiveUncomPool {
/// All commands in the pool
conflicts: Commands,
}

impl ConflictPoolOp for XorUncomPool {
impl ConflictPoolOp for ExclusiveUncomPool {
type Entry = CommandEntry<Command>;

fn all(&self) -> Vec<Self::Entry> {
Expand All @@ -175,7 +175,7 @@ impl ConflictPoolOp for XorUncomPool {
}

fn remove(&mut self, entry: Self::Entry) {
if is_xor_cmd(&entry) {
if is_exclusive_cmd(&entry) {
let _ignore = self.conflicts.remove_cmd(&entry);
}
}
Expand All @@ -189,10 +189,10 @@ impl ConflictPoolOp for XorUncomPool {
}
}

impl UncommittedPoolOp for XorUncomPool {
impl UncommittedPoolOp for ExclusiveUncomPool {
fn insert(&mut self, entry: Self::Entry) -> bool {
let mut conflict = !self.conflicts.is_empty();
if is_xor_cmd(&entry) {
if is_exclusive_cmd(&entry) {
self.conflicts.push_cmd(entry);
// Always returns conflict when the command conflicts with all other commands
conflict = true;
Expand Down

0 comments on commit 6e0a111

Please sign in to comment.