1
Deuce STM을 처음 사용하고 Deuce STM을 사용하여 대기열을 구현하는 방법에 대해 궁금합니다. 다음은 현재 수행중인 작업입니다. -대기열 Deuce STM 사용
Node 클래스에는 value와 두 번째 필드에 대한 포인터의 두 필드가 있습니다.
public class STMQueue {
Node head, tail;
public STMQueue() {
Node sentinel = new Node(-1);
tail = sentinel;
head = sentinel;
}
@Atomic
public void enq(int x) {
Node node = new Node(x);
tail.next = node;
tail = node;
}
@Atomic
public int deq() throws EmptyException{
Node node = head.next;
if(node == null) {
throw new EmptyException();
}
int retVal = node.value;
head = node;
return retVal;
}
}
올바른 구현 방법입니까? 수동으로 트랜잭션 예외를 발생시켜야합니까? 이것이 맞다면, 우리는 트랜잭션 수를 측정하고 을 어떻게 재 시도 할 것인가?