Skip to content

Commit

Permalink
Add some commments
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee-Janggun committed Aug 29, 2024
1 parent 0918c76 commit bbd6112
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lockfree/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ use core::sync::atomic::Ordering::*;
use crossbeam_epoch::{Atomic, Guard, Owned, Shared};

/// Linked list node.
// TODO: This node type is very brittle; what if some list creates a node, and uses it to add it to
// another, separate list? Also see the discussions at <https://github.com/kaist-cp/cs431/issues/957>.
// The public API surface is way too large.
#[derive(Debug)]
pub struct Node<K, V> {
/// Mark: tag(), Tag: not needed
Expand Down
5 changes: 5 additions & 0 deletions src/lockfree/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ impl<T> Queue<T> {
.compare_exchange(tail, next, Release, Relaxed, guard);
}

// After the above load & CAS, the thread view ensures that the index of tail is greater
// than that of current head. We relase that view to the head with the below CAS,
// ensuring that the index of the new head is less than or equal to that of the tail.
//
// Note: similar reasoning is done in SC memory regarding index of head and tail.
if self
.head
.compare_exchange(head, next, Release, Relaxed, guard)
Expand Down

0 comments on commit bbd6112

Please sign in to comment.