[Question] HW6 public interface of List
doxylee opened this issue · 4 comments
doxylee commented
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.
- It seems I can't access the
.next
ofNode
. It says "fieldnext
ofNode
is private". How can I create aCursor
from theNode
insidebuckets
GrowableArray
without access to the.next
? - I can create a
Node
, but how do I insert it to thelist
? Should I use thecursor
's methods and not theList
's methods?
Lee-Janggun commented
- Use Cursor::new.
- Yes.
Lee-Janggun commented
Oh, you also want to use List::head()
, which returns a cursor to the head for you to work with.
doxylee commented
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?
Lee-Janggun commented
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>
.