kaist-cp/cs431

[Question] HW6 public interface of List

doxylee opened this issue · 4 comments

Hi, I'm trying to implement split_ordered_list, and it seems I need to use Cursor and Node of the cs431::lockfree::list, but the public interface doesn't seem to give access to its internals.

  1. It seems I can't access the .next of Node. It says "field next of Node is private". How can I create a Cursor from the Node inside buckets GrowableArray without access to the .next?
  2. I can create a Node, but how do I insert it to the list? Should I use the cursor's methods and not the List's methods?
  1. Use Cursor::new.
  2. Yes.

Oh, you also want to use List::head(), which returns a cursor to the head for you to work with.

How can I use Cursor::new where it takes Atomic<Node<K, V>> and Shared<'g, Node<K, V>> where what I can get from the buckets is Node<usize, MaybeUninit<V>>?
I think i need the bucket's node's .next to create the cursor but I can't get it.

Can you provide a code example for creating a cursor from the Node?

let atomic = self.buckets.get(index,guard);
let shared = atomic.load(SeqCst,guard);
let cursor = Cursor::new(atomic,shared);

The V in Cursor::new() is a generic parameter. For the split ordered list we instantiate it with MaybeUninit<V>.